idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
42,900
protected function reconcileInitialConfig ( OutputInterface $ output ) { $ this -> step ( ++ $ this -> step , 'Basic configuration' ) ; $ settings = $ this -> displayConfigTable ( ) ; $ confirm = $ this -> io -> confirm ( 'Would you like to edit these now?' , false ) ; if ( $ confirm === false ) { return true ; } $ com...
Selective config edit on set - up .
42,901
protected function finish ( ) { if ( $ this -> firstUser !== null ) { $ this -> step ( ++ $ this -> step , 'Setup Complete!' ) ; $ this -> writeWelcome ( ) ; $ branding = $ this -> app [ 'config' ] -> get ( '/general/branding/path' , '/bolt' ) ; $ this -> io -> listing ( [ 'You may now login to your new site with the u...
Finishing step .
42,902
protected function getBufferedOutput ( OutputInterface $ output , $ verbosity = null ) { $ buffer = new BufferedOutput ( ) ; $ buffer -> setDecorated ( $ output -> isDecorated ( ) ) ; $ buffer -> setFormatter ( $ output -> getFormatter ( ) ) ; if ( $ verbosity === null ) { $ buffer -> setVerbosity ( $ output -> getVerb...
Return a pre - configured output buffer with the same formatter and decorator in use for the passed output with optionally separate verbosity level .
42,903
protected function writeBufferedOutput ( BufferedOutput $ buffer , $ result ) { if ( $ result === 0 && $ buffer -> getVerbosity ( ) < OutputInterface :: VERBOSITY_VERBOSE ) { return ; } $ this -> io -> write ( $ buffer -> fetch ( ) ) ; }
Write buffered output to the console .
42,904
private function step ( $ step , $ message ) { $ step = 'Step ' . $ step ; $ this -> io -> block ( $ message , $ step , 'fg=white;bg=blue' , ' ' , true ) ; }
Write the current step text to output .
42,905
private function writeWelcome ( ) { $ message = sprintf ( "<info>%s</info> - %s <comment>%s</comment>.\n" , Trans :: __ ( 'nut.greeting' ) , Trans :: __ ( 'nut.version' ) , Version :: VERSION ) ; $ this -> io -> text ( $ message ) ; }
Write the welcome message .
42,906
public static function handle ( PackageEvent $ event ) { $ operation = $ event -> getOperation ( ) ; if ( $ operation instanceof InstallOperation ) { $ package = $ operation -> getPackage ( ) ; } elseif ( $ operation instanceof UpdateOperation ) { $ package = $ operation -> getTargetPackage ( ) ; } else { return ; } $ ...
Event handler for composer package events .
42,907
public static function dump ( Event $ event ) { $ composer = $ event -> getComposer ( ) ; $ extra = $ composer -> getPackage ( ) -> getExtra ( ) ; $ includeAssetsDir = realpath ( $ extra [ 'bolt-web-path' ] ) === realpath ( $ extra [ 'bolt-root-path' ] ) ; $ extensions = [ ] ; $ finder = self :: getInstalledComposerJso...
Dump the metadata for extension loading on the post - autoload - dump event .
42,908
public static function mirror ( $ source , $ dest , PackageEvent $ event ) { if ( realpath ( $ source ) === realpath ( $ dest ) ) { return ; } $ fs = new Filesystem ( ) ; try { $ fs -> mirror ( $ source , $ dest ) ; } catch ( IOException $ e ) { $ event -> getIO ( ) -> writeError ( sprintf ( 'Mirroring %s to %s failed:...
Mirror a directory if the two directories don t match .
42,909
private static function getInstalledComposerJson ( ) { $ finder = new Finder ( ) ; $ finder -> files ( ) -> name ( 'composer.json' ) -> notPath ( 'vendor/composer' ) -> depth ( 2 ) -> followLinks ( ) ; try { $ finder -> in ( [ 'vendor' ] ) ; } catch ( \ InvalidArgumentException $ e ) { } return $ finder ; }
Return all the installed extension composer . json files .
42,910
public function changeLogRecord ( $ contenttype , $ contentid ) { $ options = [ 'contentid' => $ contentid , 'limit' => 4 , 'order' => 'date' , 'direction' => 'DESC' , ] ; $ repo = $ this -> storage ( ) -> getRepository ( Entity \ LogChange :: class ) ; $ context = [ 'contenttype' => $ contenttype , 'entries' => $ repo...
Generate the change log box for a single record in edit .
42,911
public function dashboardNews ( Request $ request ) { $ news = $ this -> getNews ( $ request -> getHost ( ) ) ; $ context = [ 'alert' => empty ( $ news [ 'alert' ] ) ? null : $ news [ 'alert' ] , 'news' => empty ( $ news [ 'news' ] ) ? null : $ news [ 'news' ] , 'information' => empty ( $ news [ 'information' ] ) ? nul...
News . Film at 11 .
42,912
public function makeUri ( Request $ request ) { $ content = $ this -> storage ( ) -> create ( $ request -> query -> get ( 'contenttypeslug' ) , $ request -> query -> all ( ) ) ; $ content -> set ( 'title' , $ request -> query -> get ( 'title' ) ) ; $ uri = $ content -> getUri ( $ request -> query -> get ( 'id' ) , $ re...
Generate a URI based on request parameters .
42,913
public function omnisearch ( Request $ request ) { $ query = $ request -> query -> get ( 'q' , '' ) ; if ( strlen ( $ query ) < 3 ) { return $ this -> json ( [ ] ) ; } $ options = $ this -> app [ 'omnisearch' ] -> query ( $ query ) ; return $ this -> json ( $ options ) ; }
Perform an OmniSearch search and return the results .
42,914
public function popularTags ( Request $ request , $ taxonomytype ) { $ table = $ this -> getOption ( 'general/database/prefix' ) ; $ table .= 'taxonomy' ; $ query = $ this -> createQueryBuilder ( ) -> select ( 'name, COUNT(slug) AS count' ) -> from ( $ table ) -> where ( 'taxonomytype = :taxonomytype' ) -> groupBy ( 'n...
Fetch a JSON encoded set of the most popular taxonomy specific tags .
42,915
public function readme ( ExtensionInterface $ extension ) { $ file = null ; foreach ( [ 'README.md' , 'readme.md' ] as $ possibleName ) { $ file = $ extension -> getBaseDirectory ( ) -> getFile ( $ possibleName ) ; if ( $ file -> exists ( ) ) { break ; } } if ( $ file === null ) { throw new NotFoundHttpException ( 'Not...
Render an extension s README . md file .
42,916
public function tags ( $ taxonomytype ) { $ table = $ this -> getOption ( 'general/database/prefix' ) ; $ table .= 'taxonomy' ; $ query = $ this -> createQueryBuilder ( ) -> select ( "DISTINCT $table.name" ) -> from ( $ table ) -> where ( 'taxonomytype = :taxonomytype' ) -> orderBy ( 'name' , 'ASC' ) -> setParameters (...
Fetch a JSON encoded set of taxonomy specific tags .
42,917
private function fetchNews ( $ hostname ) { $ source = $ this -> getOption ( 'general/branding/news_source' , 'https://news.bolt.cm/' ) ; $ options = $ this -> fetchNewsOptions ( $ hostname ) ; $ this -> app [ 'logger.system' ] -> info ( 'Fetching from remote server: ' . $ source , [ 'event' => 'news' ] ) ; try { $ fet...
Get the news from Bolt HQ .
42,918
private function fetchNewsOptions ( $ hostname ) { $ driver = $ this -> app [ 'db' ] -> getDatabasePlatform ( ) -> getName ( ) ; $ options = [ 'query' => [ 'v' => Bolt \ Version :: VERSION , 'p' => PHP_VERSION , 'db' => $ driver , 'name' => $ hostname , ] , 'connect_timeout' => 5 , 'timeout' => 10 , ] ; if ( $ this -> ...
Get the guzzle options .
42,919
private function getLastmodifiedByContentLog ( $ contenttypeslug , $ contentid ) { $ contenttype = $ this -> getContentType ( $ contenttypeslug ) ; $ options = [ 'limit' => 5 , 'order' => 'date' , 'direction' => 'DESC' ] ; if ( ( int ) $ contentid == 0 ) { $ isFiltered = false ; } else { $ isFiltered = true ; $ options...
Get last modified records from the content log .
42,920
private function build ( ArrayObject $ select , array $ fields , $ prefix = null ) { foreach ( $ fields as $ name => $ field ) { if ( $ field [ 'type' ] === 'repeater' ) { $ subField = new ArrayObject ( ) ; $ this -> build ( $ subField , $ field [ 'fields' ] ) ; if ( $ prefix ) { $ select [ $ prefix ] [ $ name ] = iter...
Build the select array object .
42,921
private function getYamlValues ( Bag $ field ) { $ values = array_slice ( $ field -> get ( 'values' , [ ] ) , 0 , $ field -> get ( 'limit' , self :: DEFAULT_LIMIT ) , true ) ; if ( $ field -> get ( 'sortable' ) ) { asort ( $ values , SORT_REGULAR ) ; } return $ values ; }
Return a YAML defined array of select field value options .
42,922
private function getEntityValues ( Bag $ field ) { $ baseParts = explode ( '/' , $ field -> get ( 'values' ) ) ; if ( count ( $ baseParts ) < 2 ) { throw new \ InvalidArgumentException ( sprintf ( 'The "values" key for a ContentType select must be in the form of ContentType/field_name but "%s" given' , $ field -> get (...
Return select field value options from a ContentType s records .
42,923
public function query ( QueryInterface $ query , ClassMetadata $ metadata ) { $ field = $ this -> mapping [ 'fieldname' ] ; foreach ( $ query -> getFilters ( ) as $ filter ) { if ( $ filter -> getKey ( ) == $ field ) { $ this -> rewriteQueryFilterParameters ( $ filter , $ query , $ field ) ; } } return null ; }
Repeater fields can allow filters on the value of a sub - field
42,924
protected function rewriteQueryFilterParameters ( Filter $ filter , SelectQuery $ query , $ field ) { $ boltName = $ query -> getContentType ( ) ; $ newExpression = $ this -> em -> createExpressionBuilder ( ) ; $ count = 0 ; foreach ( $ query -> getWhereParametersFor ( $ field ) as $ paramKey => $ paramValue ) { $ para...
This method does an in - place modification of a generic ContentType . field query to the format actually used in the raw SQL . For instance a simple query might say entries . repeater = title = %Test% but now we are in the context of entries the actual SQL fragment needs to do a sub - select on the bolt_field_value ta...
42,925
public function load ( QueryBuilder $ query , ClassMetadata $ metadata ) { $ field = $ this -> mapping [ 'fieldname' ] ; $ boltname = $ metadata -> getBoltName ( ) ; $ table = $ this -> mapping [ 'tables' ] [ 'field_value' ] ; $ from = $ query -> getQueryPart ( 'from' ) ; if ( isset ( $ from [ 0 ] [ 'alias' ] ) ) { $ a...
For repeating fields the load method adds extra joins and selects to the query that fetches the related records from the field and field value tables in the same query as the content fetch .
42,926
public function set ( $ entity , $ val ) { if ( $ val === null ) { $ val = new RepeatingFieldCollection ( $ this -> em , $ this -> mapping ) ; } return parent :: set ( $ entity , $ val ) ; }
The set method gets called directly by a new entity builder . For this field we never want to allow null values rather we want an empty collection so this overrides the default and handles that .
42,927
public function normalize ( $ entity ) { $ key = $ this -> mapping [ 'fieldname' ] ; $ accessor = 'get' . ucfirst ( $ key ) ; $ outerCollection = $ entity -> $ accessor ( ) ; if ( ! $ outerCollection instanceof RepeatingFieldCollection ) { $ collection = new RepeatingFieldCollection ( $ this -> em , $ this -> mapping )...
Normalize step ensures that we have correctly hydrated objects at the collection and entity level .
42,928
protected function getExistingFields ( $ entity ) { $ repo = $ this -> em -> getRepository ( Entity \ FieldValue :: class ) ; return $ repo -> getExistingFields ( $ entity -> getId ( ) , $ entity -> getContenttype ( ) , $ this -> mapping [ 'fieldname' ] ) ; }
Get existing fields for this record .
42,929
public function getImage ( ) { if ( empty ( $ this -> contenttype [ 'fields' ] ) ) { return '' ; } foreach ( $ this -> contenttype [ 'fields' ] as $ key => $ field ) { if ( $ field [ 'type' ] === 'image' && isset ( $ this -> values [ $ key ] ) ) { if ( is_array ( $ this -> values [ $ key ] ) ) { return isset ( $ this -...
Get the first image in the content .
42,930
public function getTitle ( $ allowBasicTags = false ) { $ titleParts = [ ] ; if ( $ allowBasicTags === true ) { $ allowedTags = '<b><del><em><i><strong><s>' ; } else { $ allowedTags = '' ; } foreach ( $ this -> getTitleColumnName ( ) as $ fieldName ) { $ value = is_array ( $ this -> values [ $ fieldName ] ) ? implode (...
Get the title name caption or subject .
42,931
public function getTitleColumnName ( ) { if ( ! empty ( $ this -> contenttype [ 'title_format' ] ) ) { return ( array ) $ this -> contenttype [ 'title_format' ] ; } $ names = [ 'title' , 'name' , 'caption' , 'subject' , 'heading' ] ; $ names = array_merge ( $ names , [ 'titel' , 'naam' , 'onderwerp' ] ) ; $ names = arr...
Get the columnname of the title name caption or subject .
42,932
public static function fromComposer ( IOInterface $ io ) { $ input = new ArrayInput ( [ ] ) ; $ input -> setInteractive ( $ io -> isInteractive ( ) ) ; if ( $ io instanceof ConsoleIO ) { $ ref = new \ ReflectionProperty ( $ io , 'output' ) ; $ ref -> setAccessible ( true ) ; $ output = $ ref -> getValue ( $ io ) ; if (...
Create from Composer IO .
42,933
private function getRequiredPool ( $ packageName , $ textConstraint , $ onlyLocal ) { if ( $ onlyLocal === false ) { return $ this -> getPool ( ) ; } $ composer = $ this -> getComposer ( ) ; $ pool = new Pool ( ) ; $ platformOverrides = $ composer -> getConfig ( ) -> get ( 'platform' ) ? : [ ] ; $ rootPackage = $ compo...
If the version we ask for is not installed then we need to locate it in remote repos and add it .
42,934
private function getDependencies ( array $ results ) { $ dependencies = [ ] ; $ doubles = [ ] ; foreach ( $ results as $ name => $ result ) { $ type = $ this -> recursive ? Dependency :: PROHIBITS : Dependency :: DEPENDS ; $ dependency = Dependency :: create ( $ name , $ type , $ result ) ; $ unique = ( string ) $ depe...
Assembles and prints a bottom - up table of the dependencies .
42,935
public function authorized ( $ prefix , $ path ) { foreach ( $ this -> blocked as $ rule ) { if ( preg_match ( $ rule , $ path ) ) { return false ; } } foreach ( $ this -> allowedPrefixes as $ allowedPrefix ) { if ( $ allowedPrefix === $ prefix ) { return true ; } } foreach ( $ this -> allowed as $ rule ) { if ( preg_m...
Check if you can do something with the given file or directory .
42,936
public function allowedUpload ( $ originalFilename ) { if ( Ini :: getBool ( 'file_uploads' ) === false ) { throw new IOException ( 'File uploads are not allowed, check the file_uploads ini directive.' ) ; } if ( $ originalFilename [ 0 ] === '.' ) { return false ; } $ extension = pathinfo ( $ originalFilename , PATHINF...
Checks if a given file is acceptable for upload .
42,937
public function getMaxUploadSize ( ) { if ( ! isset ( $ this -> maxUploadSize ) ) { $ size = Ini :: getBytes ( 'post_max_size' ) ; $ uploadMax = Ini :: getBytes ( 'upload_max_filesize' ) ; if ( ( $ uploadMax > 0 ) && ( $ uploadMax < $ size ) ) { $ size = $ uploadMax ; } else { $ size *= 0.995 ; } $ this -> maxUploadSiz...
Get the maximum upload size the server is configured to accept .
42,938
public function matches ( $ alteration , $ propertyName , $ before , $ after ) { if ( $ this -> alteration === $ alteration && $ this -> propertyName === $ propertyName && $ this -> before === $ before && $ this -> after === $ after ) { return true ; } return false ; }
Check if parameters match object parameters .
42,939
public static function registerCaster ( AbstractCloner $ cloner ) { $ caster = static function ( $ obj , array $ a , Stub $ stub , $ isNested , $ filter ) { if ( ! $ obj -> transparent ) { return $ a ; } $ stub -> class = $ obj -> getProxiedClass ( ) ; $ object = $ obj -> getProxiedObject ( ) ; if ( is_array ( $ object...
Registers caster for this class .
42,940
private function getReturnTo ( Request $ request , Button $ button ) { $ name = $ button -> getName ( ) ; $ isAjax = $ request -> isXmlHttpRequest ( ) ; if ( $ request -> attributes -> has ( '_test' ) ) { return 'test' ; } if ( $ name === 'save' ) { return $ isAjax ? 'ajax' : $ name ; } return $ name ; }
Calculate the parameter used to determine response .
42,941
public function overview ( Request $ request , $ contenttypeslug ) { if ( ! $ this -> isAllowed ( 'contenttype:' . $ contenttypeslug ) ) { $ this -> flashes ( ) -> error ( Trans :: __ ( 'general.phrase.access-denied-privilege-view-page' ) ) ; return $ this -> redirectToRoute ( 'dashboard' ) ; } $ taxonomy = null ; fore...
Content type overview page .
42,942
private function checkEditAccess ( $ contenttypeslug , $ id ) { $ new = empty ( $ id ) ? : false ; $ perm = $ new ? "contenttype:$contenttypeslug:create" : "contenttype:$contenttypeslug:edit:$id" ; if ( ! $ this -> isAllowed ( $ perm ) ) { $ action = $ new ? 'create' : 'edit' ; $ this -> flashes ( ) -> error ( Trans ::...
Check that the user is allowed to edit the record .
42,943
private function getEditReferrer ( Request $ request ) { $ tmp = parse_url ( $ request -> server -> get ( 'HTTP_REFERER' ) ) ; $ referrer = $ tmp [ 'path' ] ; if ( ! empty ( $ tmp [ 'query' ] ) ) { $ referrer .= '?' . $ tmp [ 'query' ] ; } if ( strpos ( $ referrer , '/overview/' ) !== false || ( $ referrer === $ this -...
Set the editreferrer in twig if it was not set yet .
42,944
public function failConnect ( FailedConnectionEvent $ args ) { $ e = $ args -> getException ( ) ; $ this -> logger -> debug ( $ e -> getMessage ( ) , [ 'event' => 'exception' , 'exception' => $ e ] ) ; throw new DatabaseConnectionException ( $ args -> getDriver ( ) -> getName ( ) , $ e -> getMessage ( ) , $ e ) ; }
Event fired on database connection failure .
42,945
public function postConnect ( ConnectionEventArgs $ args ) { $ db = $ args -> getConnection ( ) ; $ platform = $ args -> getDatabasePlatform ( ) ; $ platformName = $ platform -> getName ( ) ; if ( $ platformName === 'sqlite' ) { $ db -> query ( 'PRAGMA synchronous = OFF' ) ; } elseif ( $ platformName === 'mysql' ) { $ ...
After connecting update this connection s database settings .
42,946
public static function filesizeToBytes ( $ size ) { $ unit = preg_replace ( '/[^bkmgtpezy]/i' , '' , $ size ) ; $ size = preg_replace ( '/[^0-9\.]/' , '' , $ size ) ; if ( $ unit ) { return round ( $ size * pow ( 1024 , stripos ( 'bkmgtpezy' , $ unit [ 0 ] ) ) ) ; } return round ( $ size ) ; }
Convert a size string such as 5M to bytes .
42,947
public static function safeFilename ( $ filename ) { Deprecated :: method ( 3.0 ) ; $ filename = rawurlencode ( $ filename ) ; $ filename = str_replace ( '%2F' , '/' , $ filename ) ; if ( substr ( $ filename , 0 , 1 ) == '/' ) { $ filename = substr ( $ filename , 1 ) ; } return $ filename ; }
Encodes a filename for use in thumbnails magnific popup etc .
42,948
public static function smartUnserialize ( $ str , $ assoc = true ) { if ( $ str [ 0 ] === '{' || $ str [ 0 ] === '[' ) { return Json :: parse ( $ str , $ assoc ) ; } return Serialization :: parse ( $ str ) ; }
Leniently decode a serialized compound data structure detecting whether it s dealing with JSON - encoded data or a PHP - serialized string .
42,949
public function asArray ( ) { $ a = get_object_vars ( $ this ) ; $ a [ 'showing_from' ] = $ this -> showingFrom ; $ a [ 'showing_to' ] = $ this -> showingTo ; unset ( $ a [ 'manager' ] ) ; return $ a ; }
For v2 and v3 BC reasons .
42,950
public function getMap ( ) { return [ Target :: END_OF_HEAD => 'headTagEnd' , Target :: AFTER_HEAD_JS => 'headTagEnd' , Target :: AFTER_HEAD_CSS => 'headTagEnd' , Target :: AFTER_HEAD_META => 'headTagEnd' , Target :: BEFORE_CSS => 'cssTagsBefore' , Target :: BEFORE_JS => 'jsTagsBefore' , Target :: AFTER_META => 'metaTa...
Get a map of function names to locations .
42,951
protected function metaTagsAfter ( AssetInterface $ asset , $ rawHtml ) { if ( $ matches = $ this -> getMatches ( $ rawHtml , '<meta' , true , true ) ) { $ last = count ( $ matches [ 0 ] ) - 1 ; $ replacement = sprintf ( "%s\n%s%s" , $ matches [ 0 ] [ $ last ] , $ matches [ 1 ] [ $ last ] , ( string ) $ asset ) ; retur...
Helper function to insert some HTML into the head section of an HTML page .
42,952
protected function jsTagsAfter ( $ asset , $ rawHtml , $ insidehead = false ) { if ( $ insidehead ) { $ pos = strpos ( $ rawHtml , '</head>' ) ; $ context = substr ( $ rawHtml , 0 , $ pos ) ; } else { $ context = $ rawHtml ; } if ( $ matches = $ this -> getMatches ( $ context , '(.*)</script>' , false , true ) ) { $ la...
Helper function to insert some HTML after the last javascript include . First in the head section but if there is no script in the head place it anywhere .
42,953
private function getMatches ( $ rawHtml , $ htmlTag , $ matchRemainder , $ matchAll ) { $ matches = null ; $ matchRemainder = $ matchRemainder ? '(.*)' : '' ; $ regex = sprintf ( "~^([ \t]*)%s%s~mi" , $ htmlTag , $ matchRemainder ) ; if ( $ matchAll && preg_match_all ( $ regex , $ rawHtml , $ matches ) ) { return $ mat...
Get a set of matches .
42,954
public function load ( QueryBuilder $ query , ClassMetadata $ metadata ) { $ field = $ this -> mapping [ 'fieldname' ] ; $ target = $ this -> mapping [ 'target' ] ; $ boltname = $ metadata -> getBoltName ( ) ; if ( $ this -> mapping [ 'data' ] [ 'has_sortorder' ] ) { $ order = "$field.sortorder" ; $ query -> addSelect ...
For the taxonomy field the load event modifies the query to fetch taxonomies related to a content record from the join table .
42,955
protected function getExistingTaxonomies ( $ entity ) { $ query = $ this -> em -> createQueryBuilder ( ) -> select ( '*' ) -> from ( $ this -> mapping [ 'target' ] ) -> where ( 'content_id = :content_id' ) -> andWhere ( 'contenttype = :contenttype' ) -> andWhere ( 'taxonomytype = :taxonomytype' ) -> setParameters ( [ '...
Direct query to get existing taxonomy records .
42,956
private function updateComposerJson ( JsonFile $ jsonFile , array $ package , $ isPostInstall ) { $ composerJson = $ jsonFile -> parse ( ) ; $ sortPackages = $ this -> getOptions ( ) -> sortPackages ( ) ; $ requireKey = $ this -> getOptions ( ) -> dev ( ) ? 'require-dev' : 'require' ; $ removeKey = $ this -> getOptions...
Update the JSON file .
42,957
private function updateFileCleanly ( JsonFile $ jsonFile , array $ new , $ requireKey , $ removeKey , $ sortPackages , $ isPostInstall ) { $ composerJson = $ jsonFile -> read ( ) ; $ manipulator = new JsonManipulator ( $ composerJson ) ; foreach ( $ new as $ package => $ constraint ) { $ constraint = $ isPostInstall ? ...
Cleanly update a Composer JSON file .
42,958
public function setFileName ( $ fileName ) { if ( is_array ( $ fileName ) ) { $ rawFileName = isset ( $ fileName [ 'filename' ] ) ? $ fileName [ 'filename' ] : ( isset ( $ fileName [ 'file' ] ) ? $ fileName [ 'file' ] : null ) ; $ this -> title = isset ( $ fileName [ 'title' ] ) ? $ fileName [ 'title' ] : $ this -> tit...
Set the file name .
42,959
public function setWidth ( $ width , $ default = 100 ) { if ( ! is_numeric ( $ width ) ) { $ width = empty ( $ this -> thumbConf [ 'default_thumbnail' ] [ 0 ] ) ? $ default : $ this -> thumbConf [ 'default_thumbnail' ] [ 0 ] ; } $ this -> width = $ width ; return $ this ; }
Set the thumbnail width .
42,960
public function setHeight ( $ height , $ default = 100 ) { if ( ! is_numeric ( $ height ) ) { $ height = empty ( $ this -> thumbConf [ 'default_thumbnail' ] [ 1 ] ) ? $ default : $ this -> thumbConf [ 'default_thumbnail' ] [ 1 ] ; } $ this -> height = $ height ; return $ this ; }
Set the thumbnail height .
42,961
public function setScale ( $ scale ) { $ valid = [ 'b' , 'c' , 'f' , 'r' ] ; $ scale = substr ( ( string ) $ scale , 0 , 1 ) ; $ scale = in_array ( $ scale , $ valid ) ? $ scale : ( ! empty ( $ this -> thumbConf [ 'cropping' ] ) ? substr ( $ this -> thumbConf [ 'cropping' ] , 0 , 1 ) : 'c' ) ; $ this -> scale = $ scale...
Set the thumbnail scaling method .
42,962
public function queryTrimLog ( $ period ) { $ qb = $ this -> createQueryBuilder ( ) ; $ qb -> delete ( $ this -> getTableName ( ) ) -> where ( 'date < :date' ) -> setParameter ( 'date' , $ period , Type :: DATETIME ) ; return $ qb ; }
Build the query for a log trim .
42,963
public function clearLog ( ) { $ qb = $ this -> createQueryBuilder ( ) ; $ query = $ qb -> getConnection ( ) -> getDatabasePlatform ( ) -> getTruncateTableSQL ( $ this -> getTableName ( ) ) ; return $ qb -> getConnection ( ) -> executeQuery ( $ query ) -> execute ( ) ; }
Clear the log table .
42,964
public function getActivity ( $ page = 1 , $ amount = 10 , array $ options = [ ] ) { $ query = $ this -> getActivityQuery ( $ page , $ amount , $ options ) ; return $ this -> findWith ( $ query ) ; }
Get content log s activity entries .
42,965
public function getActivityQuery ( $ page , $ amount , array $ options ) { $ qb = $ this -> createQueryBuilder ( ) ; $ qb -> select ( '*' ) -> orderBy ( 'id' , 'DESC' ) -> setMaxResults ( ( int ) $ amount ) -> setFirstResult ( ( int ) ( ( $ page - 1 ) * $ amount ) ) ; $ this -> addWhereActivity ( $ qb , $ options ) ; r...
Build the query to get the log entries .
42,966
public function getActivityCountQuery ( array $ options ) { $ qb = $ this -> createQueryBuilder ( ) ; $ qb -> select ( 'COUNT(id) as count' ) ; $ this -> addWhereActivity ( $ qb , $ options ) ; return $ qb ; }
Build the query for the entry count .
42,967
protected function addWhereActivity ( QueryBuilder $ qb , $ options ) { if ( empty ( $ options ) ) { return ; } foreach ( $ options as $ columnName => $ option ) { if ( is_array ( $ options [ $ columnName ] ) ) { $ qb -> andWhere ( $ this -> buildWhereOr ( $ qb , $ columnName , $ option ) ) ; } elseif ( ! empty ( $ opt...
Add required WHERE parameters .
42,968
protected function buildWhereOr ( QueryBuilder $ qb , $ parentColumnName , array $ options ) { $ orX = $ qb -> expr ( ) -> orX ( ) ; foreach ( $ options as $ columnName => $ option ) { if ( empty ( $ options [ $ columnName ] ) ) { continue ; } elseif ( Arr :: isIndexed ( $ options ) ) { $ key = $ parentColumnName . '_'...
Build an OR group that is added to the AND .
42,969
public function update ( ) { if ( ! file_exists ( static :: FILENAME ) ) { return ; } $ contents = Yaml :: parse ( file_get_contents ( static :: FILENAME ) ) ? : [ ] ; if ( ! isset ( $ contents [ 'paths' ] ) ) { return ; } $ originalPaths = $ contents [ 'paths' ] ; $ contents [ 'paths' ] = $ newPaths = $ this -> update...
Update . bolt . yml file if needed .
42,970
private function determineMostCommonBaseAppPath ( $ paths ) { $ paths = array_values ( $ paths ) ; $ options = [ ] ; $ options [ ] = Path :: getLongestCommonBasePath ( $ paths ) ; if ( isset ( $ paths [ 1 ] ) ) { $ options [ ] = Path :: getLongestCommonBasePath ( [ $ paths [ 0 ] , $ paths [ 1 ] ] ) ; } if ( isset ( $ p...
Determine the most common app path .
42,971
public static function filter ( Request $ request ) { $ bags = MutableBag :: from ( array_fill_keys ( [ 'attributes' , 'query' , 'files' , 'cookies' , 'headers' , 'server' ] , null ) ) ; foreach ( $ bags -> keys ( ) as $ key ) { $ bags [ $ key ] = static :: getValues ( $ request -> $ key -> all ( ) ) ; } if ( $ request...
Filter a request object to be safe to pass to Twig .
42,972
public function getContentObject ( $ contenttype , $ values = [ ] , $ isRootType = true ) { if ( ! is_array ( $ contenttype ) ) { $ contenttype = $ this -> getContentType ( $ contenttype ) ; } if ( ! empty ( $ contenttype [ 'class' ] ) && class_exists ( $ contenttype [ 'class' ] ) ) { $ content = new $ contenttype [ 'c...
Get an object for the content of a specific contenttype . This will be \ Bolt \ Legacy \ Content unless the contenttype defined another class to be used .
42,973
public function preFill ( $ contentTypes = [ ] ) { if ( empty ( $ contentTypes ) ) { $ contentTypes = $ this -> app [ 'config' ] -> get ( 'contenttypes' ) ; $ contentTypeNames = array_keys ( $ contentTypes ) ; } else { $ contentTypeNames = ( array ) $ contentTypes ; } $ builder = $ this -> app [ 'prefill.builder' ] ; $...
Add some records with dummy content .
42,974
private function logInsert ( $ contenttype , $ contentid , $ content , $ comment = null ) { $ this -> app [ 'logger.change' ] -> info ( 'Insert record' , [ 'action' => 'INSERT' , 'contenttype' => $ contenttype , 'id' => $ contentid , 'new' => $ content , 'old' => null , 'comment' => $ comment , ] ) ; }
Writes a content - changelog entry for a newly - created entry .
42,975
public function saveContent ( Content $ content , $ comment = null ) { $ contenttype = $ content -> contenttype ; $ fieldvalues = $ content -> values ; if ( empty ( $ contenttype ) ) { $ this -> app [ 'logger.system' ] -> error ( 'Contenttype is required for ' . __FUNCTION__ , [ 'event' => 'exception' ] ) ; throw new S...
Save a record .
42,976
protected function insertContent ( Content $ content , $ comment = null ) { $ tablename = $ this -> getContenttypeTablename ( $ content -> contenttype ) ; $ content -> setValue ( 'datecreated' , date ( 'Y-m-d H:i:s' ) ) ; $ content -> setValue ( 'datechanged' , date ( 'Y-m-d H:i:s' ) ) ; unset ( $ content -> values [ '...
Insert a new contenttype record in the database .
42,977
private function updateContent ( Content $ content , $ comment = null ) { $ tablename = $ this -> getContenttypeTablename ( $ content -> contenttype ) ; $ content -> setValue ( 'datechanged' , date ( 'Y-m-d H:i:s' ) ) ; $ oldContent = $ this -> findContent ( $ tablename , $ content [ 'id' ] ) ; if ( empty ( $ oldConten...
Update a Bolt contenttype record .
42,978
private function getValidSaveData ( array $ fieldvalues , array $ contenttype ) { foreach ( array_keys ( $ fieldvalues ) as $ key ) { if ( $ this -> isValidColumn ( $ key , $ contenttype ) ) { if ( is_string ( $ fieldvalues [ $ key ] ) ) { $ fieldvalues [ $ key ] = trim ( $ fieldvalues [ $ key ] ) ; } elseif ( is_bool ...
Get a valid array to commit .
42,979
public function updateSingleValue ( $ contenttype , $ id , $ field , $ value ) { $ id = intval ( $ id ) ; if ( ! $ this -> isValidColumn ( $ field , $ contenttype ) ) { $ error = Trans :: __ ( 'contenttypes.generic.invalid-field' , [ '%field%' => $ field , '%contenttype%' => $ contenttype ] ) ; $ this -> app [ 'logger....
Update a single value from content .
42,980
private function decodeSearchQuery ( $ q ) { $ words = preg_split ( '|[\r\n\t ]+|' , trim ( $ q ) ) ; $ words = array_map ( function ( $ word ) { return mb_strtolower ( $ word ) ; } , $ words ) ; $ words = array_filter ( $ words , function ( $ word ) { return strlen ( $ word ) >= 2 ; } ) ; return [ 'valid' => count ( $...
Decode search query into searchable parts .
42,981
private function compareSearchWeights ( Content $ a , Content $ b ) { if ( $ a -> getSearchResultWeight ( ) > $ b -> getSearchResultWeight ( ) ) { return - 1 ; } if ( $ a -> getSearchResultWeight ( ) < $ b -> getSearchResultWeight ( ) ) { return 1 ; } if ( $ a [ 'datepublish' ] > $ b [ 'datepublish' ] ) { return - 1 ; ...
Compare by search weights .
42,982
public function searchContent ( $ q , array $ contenttypes = null , array $ filters = null , $ limit = 9999 , $ offset = 0 ) { $ query = $ this -> decodeSearchQuery ( $ q ) ; if ( ! $ query [ 'valid' ] ) { return false ; } $ appCt = $ this -> app [ 'config' ] -> get ( 'contenttypes' ) ; if ( is_null ( $ contenttypes ) ...
Search through actual content .
42,983
private function organizeQueryParameters ( $ inParameters = null ) { $ ctypeParameters = [ ] ; $ metaParameters = [ ] ; if ( is_array ( $ inParameters ) ) { foreach ( $ inParameters as $ key => $ value ) { if ( in_array ( $ key , [ 'page' , 'limit' , 'offset' , 'returnsingle' , 'printquery' , 'paging' , 'order' ] ) ) {...
Split into meta - parameters and contenttype parameters .
42,984
private function decodeContentTypesFromText ( $ text ) { $ contenttypes = [ ] ; if ( ( substr ( $ text , 0 , 1 ) == '(' ) && ( substr ( $ text , - 1 ) == ')' ) ) { $ contenttypes = explode ( ',' , substr ( $ text , 1 , - 1 ) ) ; } else { $ contenttypes [ ] = $ text ; } $ instance = $ this ; $ contenttypes = array_map (...
Decode a contenttypes argument from text .
42,985
private function prepareDecodedQueryForUse ( & $ decoded , & $ metaParameters , & $ ctypeParameters ) { if ( count ( $ decoded [ 'contenttypes' ] ) == 1 ) { $ ctypeParameters = [ $ decoded [ 'contenttypes' ] [ 0 ] => $ ctypeParameters ] ; } else { $ globalParameters = [ ] ; foreach ( $ ctypeParameters as $ key => $ par...
Prepare decoded for actual use .
42,986
private function decodeQueryOrder ( $ contenttype , $ orderValue ) { $ order = false ; if ( ( $ orderValue === false ) || ( $ orderValue === '' ) ) { if ( $ this -> isValidColumn ( $ contenttype [ 'sort' ] , $ contenttype , true ) ) { $ order = $ this -> getEscapedSortorder ( $ contenttype [ 'sort' ] , false ) ; } } el...
Get the parameter for the order by part of a query .
42,987
protected function decodePageParameter ( $ context = '' , $ inParameters = null ) { if ( isset ( $ inParameters [ 'page' ] ) && $ inParameters [ 'page' ] !== null ) { return $ inParameters [ 'page' ] ; } else { $ param = Pager :: makeParameterId ( $ context ) ; $ query = $ this -> app [ 'request' ] -> query ; $ page = ...
Decodes contextual page number from current request url if found .
42,988
private function hydrateRows ( $ contenttype , $ rows , $ getTaxoAndRel = true ) { $ objects = [ ] ; foreach ( $ rows as $ row ) { $ objects [ $ row [ 'id' ] ] = $ this -> getContentObject ( $ contenttype , $ row ) ; } if ( $ getTaxoAndRel ) { $ this -> getTaxonomy ( $ objects ) ; $ this -> getRelation ( $ objects ) ; ...
Hydrate database rows into objects .
42,989
private function runContentTypeTableChecks ( array $ contenttypes ) { $ checkedcontenttype = [ ] ; foreach ( $ contenttypes as $ contenttypeslug ) { if ( isset ( $ checkedcontenttype [ $ contenttypeslug ] ) ) { continue ; } $ checkedcontenttype [ $ contenttypeslug ] = true ; $ contenttype = $ this -> getContentType ( $...
Check for the existence of ContentType tables .
42,990
private function isValidColumn ( $ name , $ contenttype , $ allowVariants = false ) { $ isValidColumn = false ; if ( $ this -> isMultiOrderQuery ( $ name ) ) { $ separatedOrders = $ this -> getOrderBys ( $ name ) ; } else { $ separatedOrders = [ $ name ] ; } foreach ( $ separatedOrders as $ index => $ name ) { $ name =...
Check if a given name is a valid column and if it can be used in queries .
42,991
private function getEscapedSortorder ( $ name , $ prefix = 'r' ) { $ order = '' ; $ separatedOrders = $ this -> getOrderBys ( $ name ) ; $ totalOrderByElements = count ( $ separatedOrders ) ; foreach ( $ separatedOrders as $ index => $ name ) { list ( $ name , $ asc ) = $ this -> getSortOrder ( $ name ) ; if ( empty ( ...
Get an escaped sortorder for use in SQL from a fieldname like title or - id .
42,992
protected function getOrderBys ( $ order ) { $ separatedOrders = [ $ order ] ; if ( $ this -> isMultiOrderQuery ( $ order ) ) { $ separatedOrders = explode ( ',' , $ order ) ; } return $ separatedOrders ; }
Get the ORDER BY parameters for the query .
42,993
public function getSortOrder ( $ name = '-datepublish' ) { if ( ! is_string ( $ name ) ) { return false ; } $ parts = explode ( ' ' , trim ( $ name ) ) ; $ fieldname = $ parts [ 0 ] ; $ sort = 'ASC' ; if ( isset ( $ parts [ 1 ] ) ) { $ sort = $ parts [ 1 ] ; } if ( $ fieldname [ 0 ] == '-' ) { $ fieldname = substr ( $ ...
Get sorting order of name stripping possible DESC ASC etc . and also return the sorting order .
42,994
private function groupingSort ( Content $ a , Content $ b ) { if ( $ a -> group [ 'slug' ] == $ b -> group [ 'slug' ] ) { if ( ! empty ( $ a -> sortorder ) || ! empty ( $ b -> sortorder ) ) { if ( ! isset ( $ a -> sortorder ) ) { return 1 ; } elseif ( ! isset ( $ b -> sortorder ) ) { return - 1 ; } else { return ( $ a ...
Helper function for sorting Records of content that have a Grouping .
42,995
private function parseWhereParameter ( $ key , $ value , $ fieldtype = false ) { $ value = trim ( $ value ) ; if ( strpos ( $ value , " || " ) !== false ) { $ values = explode ( " || " , $ value ) ; foreach ( $ values as $ index => $ value ) { $ values [ $ index ] = $ this -> parseWhereParameter ( $ key , $ value , $ f...
Helper function to set the proper where parameter when getting values like <2012 or !bob .
42,996
public function getContentTypeFields ( $ contenttypeslug ) { $ contenttype = $ this -> getContentType ( $ contenttypeslug ) ; if ( empty ( $ contenttype [ 'fields' ] ) ) { return [ ] ; } else { return array_keys ( $ contenttype [ 'fields' ] ) ; } }
Get an array of the available fields for a given contenttype .
42,997
public function getContentTypeFieldType ( $ contenttypeslug , $ fieldname ) { $ contenttype = $ this -> getContentType ( $ contenttypeslug ) ; if ( in_array ( $ fieldname , [ 'datecreated' , 'datechanged' , 'datepublish' , 'datedepublish' ] ) ) { return "datetime" ; } elseif ( isset ( $ contenttype [ 'fields' ] [ $ fie...
Get the fieldtype for a given contenttype and fieldname .
42,998
public function getContentTypeGrouping ( $ contenttypeslug ) { $ grouping = false ; $ taxonomy = $ this -> getContentTypeTaxonomy ( $ contenttypeslug ) ; foreach ( $ taxonomy as $ tax ) { if ( $ tax [ 'behaves_like' ] === 'grouping' ) { $ grouping = $ tax [ 'slug' ] ; break ; } } return $ grouping ; }
Check if a given contenttype has a grouping and if it does return it .
42,999
public function getContentTypeTaxonomy ( $ contenttypeslug ) { $ contenttype = $ this -> getContentType ( $ contenttypeslug ) ; if ( empty ( $ contenttype [ 'taxonomy' ] ) ) { return [ ] ; } else { $ taxokeys = $ contenttype [ 'taxonomy' ] ; $ taxonomy = [ ] ; foreach ( $ taxokeys as $ key ) { if ( $ this -> app [ 'con...
Get an array of the available taxonomytypes for a given contenttype .