idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
227,300
protected function loadNailsBower ( $ sAsset , $ sForceType ) { $ sType = $ this -> determineType ( $ sAsset , $ sForceType ) ; switch ( $ sType ) { case 'CSS' : $ this -> aCss [ 'NAILS-BOWER-' . $ sAsset ] = NAILS_ASSETS_URL . $ this -> sBowerDir . $ sAsset ; break ; case 'JS' : $ this -> aJs [ 'NAILS-BOWER-' . $ sAss...
Loads a Bower asset from the NAils asset module s bower_components directory
227,301
protected function loadAppBower ( $ sAsset , $ sForceType ) { $ sType = $ this -> determineType ( $ sAsset , $ sForceType ) ; switch ( $ sType ) { case 'CSS' : $ this -> aCss [ 'APP-BOWER-' . $ sAsset ] = $ this -> sBaseUrl . $ this -> sBowerDir . $ sAsset ; break ; case 'JS' : $ this -> aJs [ 'APP-BOWER-' . $ sAsset ]...
Loads a Bower asset from the app s bower_components directory
227,302
protected function loadApp ( $ sAsset , $ sForceType ) { $ sType = $ this -> determineType ( $ sAsset , $ sForceType ) ; switch ( $ sType ) { case 'CSS' : $ this -> aCss [ 'APP-' . $ sAsset ] = $ this -> sBaseUrl . $ this -> sCssDir . $ sAsset ; break ; case 'JS' : $ this -> aJs [ 'APP-' . $ sAsset ] = $ this -> sBaseU...
Loads an asset from the app s asset directory
227,303
protected function loadModule ( $ sAsset , $ sForceType , $ mModule ) { if ( is_array ( $ mModule ) ) { $ sModule = ! empty ( $ mModule [ 0 ] ) ? $ mModule [ 0 ] : null ; $ sLocation = ! empty ( $ mModule [ 1 ] ) ? $ mModule [ 1 ] : null ; } else { $ sModule = $ mModule ; $ sLocation = null ; } $ sType = $ this -> dete...
Loads an asset from a module s asset directory
227,304
public function unload ( $ mAssets , $ sAssetLocation = 'APP' , $ sForceType = null ) { $ aAssets = ( array ) $ mAssets ; $ sAssetLocation = $ sAssetLocation === true ? 'NAILS' : $ sAssetLocation ; switch ( strtoupper ( $ sAssetLocation ) ) { case 'NAILS-BOWER' : $ sAssetLocationMethod = 'unloadNailsBower' ; break ; ca...
Unloads an asset
227,305
protected function unloadUrl ( $ sAsset , $ sForceType ) { $ sType = $ this -> determineType ( $ sAsset , $ sForceType ) ; switch ( $ sType ) { case 'CSS' : unset ( $ this -> aCss [ 'URL-' . $ sAsset ] ) ; break ; case 'JS' : unset ( $ this -> aJs [ 'URL-' . $ sAsset ] ) ; break ; } }
Unloads an asset supplied as a URL
227,306
protected function unloadAbsolute ( $ sAsset , $ sForceType ) { $ sType = $ this -> determineType ( $ sAsset , $ sForceType ) ; switch ( $ sType ) { case 'CSS' : unset ( $ this -> aCss [ 'ABSOLUTE-' . $ sAsset ] ) ; break ; case 'JS' : unset ( $ this -> aJs [ 'ABSOLUTE-' . $ sAsset ] ) ; break ; } }
Unloads an asset supplied as an absolute URL
227,307
protected function unloadNails ( $ sAsset , $ sForceType ) { $ sType = $ this -> determineType ( $ sAsset , $ sForceType ) ; switch ( $ sType ) { case 'CSS' : unset ( $ this -> aCss [ 'NAILS-' . $ sAsset ] ) ; break ; case 'JS' : unset ( $ this -> aJs [ 'NAILS-' . $ sAsset ] ) ; break ; } }
Unloads an asset from the Nails asset module
227,308
protected function unloadNailsBower ( $ sAsset , $ sForceType ) { $ sType = $ this -> determineType ( $ sAsset , $ sForceType ) ; switch ( $ sType ) { case 'CSS' : unset ( $ this -> aCss [ 'NAILS-BOWER-' . $ sAsset ] ) ; break ; case 'JS' : unset ( $ this -> aJs [ 'NAILS-BOWER-' . $ sAsset ] ) ; break ; } }
Loads a Bower asset from the Nails asset module s bower_components directory
227,309
protected function unloadAppBower ( $ sAsset , $ sForceType ) { $ sType = $ this -> determineType ( $ sAsset , $ sForceType ) ; switch ( $ sType ) { case 'CSS' : unset ( $ this -> aCss [ 'APP-BOWER-' . $ sAsset ] ) ; break ; case 'JS' : unset ( $ this -> aJs [ 'APP-BOWER-' . $ sAsset ] ) ; break ; } }
Unloads a Bower asset from the app s bower_components directory
227,310
public function inline ( $ sScript = null , $ sForceType = null , $ sJsLocation = 'FOOTER' ) { if ( ! empty ( $ sScript ) ) { $ sJsLocation = strtoupper ( $ sJsLocation ) ; if ( $ sJsLocation != 'FOOTER' && $ sJsLocation != 'HEADER' ) { throw new AssetException ( '"' . $ sJsLocation . '" is not a valid inline JS locati...
Loads an inline asset
227,311
public function library ( $ sLibrary ) { switch ( strtoupper ( $ sLibrary ) ) { case 'CKEDITOR' : $ this -> load ( [ 'ckeditor/ckeditor.js' , 'ckeditor/adapters/jquery.js' , ] , 'NAILS-BOWER' ) ; break ; case 'JQUERYUI' : $ this -> load ( [ 'jquery-ui/jquery-ui.min.js' , 'jquery-ui/themes/smoothness/jquery-ui.min.css' ...
Loads a set of assets
227,312
public function clear ( ) { $ this -> aCss = [ ] ; $ this -> aCssInline = [ ] ; $ this -> aJs = [ ] ; $ this -> aJsInlineHeader = [ ] ; $ this -> aJsInlineFooter = [ ] ; return $ this ; }
Clears all loaded assets
227,313
public function getLoaded ( ) { $ oLoaded = new \ stdClass ( ) ; $ oLoaded -> css = $ this -> aCss ; $ oLoaded -> cssInline = $ this -> aCssInline ; $ oLoaded -> js = $ this -> aJs ; $ oLoaded -> jsInlineHeader = $ this -> aJsInlineHeader ; $ oLoaded -> jsInlineFooter = $ this -> aJsInlineFooter ; return $ oLoaded ; }
Returns an object containing all loaded assets useful for debugging .
227,314
public function output ( $ sType = 'ALL' , $ bOutput = true ) { $ aOut = [ ] ; $ sType = strtoupper ( $ sType ) ; if ( ! empty ( $ this -> aCss ) && ( $ sType == 'CSS' || $ sType == 'ALL' ) ) { foreach ( $ this -> aCss as $ sAsset ) { $ sAsset = $ this -> addCacheBuster ( $ sAsset ) ; $ aOut [ ] = link_tag ( $ sAsset )...
Output the assets for HTML
227,315
protected function addCacheBuster ( $ sAsset ) { if ( $ this -> sCacheBuster ) { $ aParsedUrl = parse_url ( $ sAsset ) ; if ( empty ( $ aParsedUrl [ 'query' ] ) ) { $ sAsset .= '?' ; } else { $ sAsset .= '&' ; } $ sAsset .= 'revision=' . $ this -> sCacheBuster ; } return $ sAsset ; }
Appends the cacheBuster string to the asset name accounts for existing query strings
227,316
protected function determineType ( $ sAsset , $ sForceType = null ) { if ( ! empty ( $ sForceType ) ) { return $ sForceType ; } if ( preg_match ( '/^<style.*?>.*?<\/style>$/si' , $ sAsset ) ) { return 'CSS-INLINE' ; } if ( preg_match ( '/^<script.*?>.*?<\/script>$/si' , $ sAsset ) ) { return 'JS-INLINE' ; } if ( substr...
Determines the type of asset being loaded
227,317
protected function resetProperties ( $ aProperties ) { foreach ( $ aProperties as $ aProperty ) { if ( property_exists ( $ this -> oDb , $ aProperty [ 0 ] ) ) { $ this -> oDb -> { $ aProperty [ 0 ] } = $ aProperty [ 1 ] ; } } return $ this ; }
Safely resets properties
227,318
protected function compile ( array & $ aClientConfig , array & $ aRequestOptions ) { parent :: compile ( $ aClientConfig , $ aRequestOptions ) ; $ aRequestOptions [ 'form_params' ] = $ this -> aFormParams ; }
Compile the request
227,319
private function buildMainLocationParameters ( ParameterBuilderInterface $ builder , array $ groups = [ ] ) : void { $ builder -> add ( 'only_main_locations' , ParameterType \ BooleanType :: class , [ 'default_value' => true , 'groups' => $ groups , ] ) ; }
Builds the parameters for filtering content with main location only .
227,320
private function getMainLocationFilterCriteria ( ParameterCollectionInterface $ parameterCollection ) : ? Criterion { if ( $ parameterCollection -> getParameter ( 'only_main_locations' ) -> getValue ( ) !== true ) { return null ; } return new Criterion \ Location \ IsMainLocation ( Criterion \ Location \ IsMainLocation...
Returns the criteria used to filter content with main location only .
227,321
private function loadLocation ( ) : ? Location { if ( ! $ this -> context -> has ( 'ez_location_id' ) ) { return null ; } return $ this -> locationService -> loadLocation ( ( int ) $ this -> context -> get ( 'ez_location_id' ) ) ; }
Loads the location from the eZ Platform API by using the location ID stored in the context .
227,322
private function buildQueryTypeParameters ( ParameterBuilderInterface $ builder , array $ groups = [ ] ) : void { $ builder -> add ( 'query_type' , ParameterType \ ChoiceType :: class , [ 'required' => true , 'options' => [ 'List' => 'list' , 'Tree' => 'tree' , ] , 'groups' => $ groups , ] ) ; }
Builds the parameters for selecting a query type .
227,323
private function getQueryTypeFilterCriteria ( ParameterCollectionInterface $ parameterCollection , Location $ parentLocation ) : ? Criterion { if ( $ parameterCollection -> getParameter ( 'query_type' ) -> getValue ( ) !== 'list' ) { return null ; } return new Criterion \ Location \ Depth ( Criterion \ Operator :: EQ ,...
Returns the criteria used to filter content with one of the supported query types .
227,324
public static function convert ( string $ uuid ) { $ bin = hex2bin ( str_replace ( [ '{' , '-' , '}' ] , '' , $ uuid ) ) ; $ xor = self :: xor ( ... str_split ( $ bin , 8 ) ) ; return unpack ( 'q' , $ xor ) [ 1 ] ; }
Convert a uuid to a 64 - bit signed integer .
227,325
public static function isPageSecure ( ) { if ( isset ( $ _SERVER [ 'HTTPS' ] ) && strtolower ( $ _SERVER [ 'HTTPS' ] ) === 'on' ) { return true ; } elseif ( isset ( $ _SERVER [ 'SERVER_NAME' ] ) && isset ( $ _SERVER [ 'REQUEST_URI' ] ) && SECURE_BASE_URL != BASE_URL ) { $ sUrl = 'http://' . $ _SERVER [ 'SERVER_NAME' ] ...
Detects whether the current page is secure or not
227,326
public function getAsString ( ) : string { return implode ( '_' , array_filter ( [ ( string ) $ this -> getLanguage ( ) , ( string ) $ this -> getRegion ( ) , ( string ) $ this -> getScript ( ) , ] ) ) ; }
Compute the string representation of the locale
227,327
public function write ( $ mData , string $ sKey = null ) : Item { if ( is_null ( $ sKey ) ) { $ sKey = md5 ( microtime ( true ) ) ; } $ sPath = $ this -> prepKey ( $ sKey ) ; file_put_contents ( $ sPath , $ mData ) ; return $ this -> newItem ( $ sKey ) ; }
Writes to the cache
227,328
public function read ( string $ sKey ) : ? Item { return $ this -> exists ( $ sKey ) ? $ this -> newItem ( $ sKey ) : null ; }
Reads a file from the cache
227,329
public function delete ( string $ sKey ) : bool { if ( $ this -> exists ( $ sKey ) ) { return @ unlink ( $ this -> prepKey ( $ sKey ) ) ; } else { return false ; } }
Delete a cache item
227,330
protected function newItem ( string $ sKey ) : Item { $ oObj = ( object ) [ 'sKey' => $ sKey , 'sPath' => $ this -> prepKey ( $ sKey ) , ] ; if ( defined ( 'PHPUNIT_NAILS_COMMON_TEST_SUITE' ) ) { $ oItem = new Item ( $ oObj ) ; } else { $ oItem = Factory :: resource ( 'FileCacheItem' , null , $ oObj ) ; } return $ oIte...
Configures a new item object
227,331
public static function fileExistsCS ( $ sFilename ) { if ( array_key_exists ( $ sFilename , static :: $ aFileExistsCache ) ) { return static :: $ aFileExistsCache [ $ sFilename ] ; } $ sDirectory = dirname ( $ sFilename ) ; $ aFiles = array_map ( function ( $ sFile ) { return basename ( $ sFile ) ; } , glob ( $ sDirect...
A case - sensitive file_exists
227,332
public static function isDirCS ( $ sDir ) { if ( array_key_exists ( $ sDir , static :: $ aIsDirCache ) ) { return static :: $ aIsDirCache [ $ sDir ] ; } $ aDirBits = explode ( DIRECTORY_SEPARATOR , $ sDir ) ; $ bResult = true ; while ( count ( $ aDirBits ) > 1 ) { $ sDirectory = array_pop ( $ aDirBits ) ; $ sDirectoryP...
A case - sensitive is_dir
227,333
private function getObjectStates ( Options $ options ) : array { $ allObjectStates = [ ] ; $ groups = $ this -> objectStateService -> loadObjectStateGroups ( ) ; $ configuredGroups = $ options [ 'states' ] ; foreach ( $ groups as $ group ) { $ configuredGroups += [ $ group -> identifier => true ] ; if ( $ configuredGro...
Returns the allowed content states from eZ Platform .
227,334
protected function setCache ( $ sKey , $ mValue ) { if ( ! static :: $ CACHING_ENABLED ) { return false ; } elseif ( empty ( $ sKey ) ) { return false ; } if ( function_exists ( 'ini_get' ) ) { $ sMemoryLimit = ini_get ( 'memory_limit_cat' ) ; if ( $ sMemoryLimit !== false ) { $ sLastChar = strtoupper ( $ sMemoryLimit ...
Saves an item to the cache
227,335
protected function setCacheAlias ( $ sAliasKey , $ sOriginalKey ) { if ( ! static :: $ CACHING_ENABLED ) { return false ; } elseif ( empty ( $ sAliasKey ) || empty ( $ sOriginalKey ) ) { return false ; } $ sOriginalCacheKey = $ this -> getCache ( $ sOriginalKey , false ) ; if ( is_null ( $ sOriginalCacheKey ) ) { retur...
Adds an additional key to an existing cache item
227,336
protected function getCache ( $ sKey , $ bReturnValue = true ) { if ( ! static :: $ CACHING_ENABLED ) { return false ; } elseif ( empty ( $ sKey ) ) { return false ; } $ sCacheKey = $ this -> getCachePrefix ( ) . $ sKey ; foreach ( $ this -> aCache as $ iIndex => $ oCacheItem ) { if ( in_array ( $ sCacheKey , $ oCacheI...
Fetches an item from the cache
227,337
protected function unsetCachePrefix ( $ sPrefix ) { if ( ! static :: $ CACHING_ENABLED ) { return false ; } elseif ( empty ( $ sPrefix ) ) { return false ; } $ sPrefix = $ this -> getCachePrefix ( ) . $ sPrefix ; $ aKeysToUnset = [ ] ; foreach ( $ this -> aCache as $ sCacheKey => $ oCacheItem ) { foreach ( $ oCacheItem...
Deletes item from the cache which match a particular prefix
227,338
public function execute ( ) { $ oModel = Factory :: model ( static :: CONFIG_MODEL_NAME , static :: CONFIG_MODEL_PROVIDER ) ; $ oLocale = Factory :: service ( 'Locale' ) ; $ oDefaultLocale = $ oLocale -> getDefautLocale ( ) ; $ aFieldsDescribed = $ oModel -> describeFields ( ) ; $ aFields = [ ] ; foreach ( $ aFieldsDes...
Execute the seed
227,339
protected function generate ( $ aFields ) { $ aOut = [ ] ; foreach ( $ aFields as $ oField ) { switch ( $ oField -> type ) { case 'textarea' : $ mValue = $ this -> loremParagraph ( ) ; break ; case 'wysiwyg' : $ mValue = $ this -> loremHtml ( ) ; break ; case 'number' : $ mValue = $ this -> randomInteger ( ) ; break ; ...
Generate a new item
227,340
public function setFile ( $ sFile = '' ) { $ this -> oLog -> exists = false ; if ( ! empty ( $ sFile ) ) { $ this -> oLog -> file = $ sFile ; } else { $ oDate = Factory :: factory ( 'DateTime' ) ; $ this -> oLog -> file = 'log-' . $ oDate -> format ( 'Y-m-d' ) . '.php' ; } }
Set the filename which is being written to
227,341
public function setDir ( $ sDir = '' ) { $ this -> oLog -> exists = false ; if ( ! empty ( $ sDir ) && substr ( $ sDir , 0 , 1 ) === '/' ) { $ this -> oLog -> dir = $ sDir ; } elseif ( ! empty ( $ sDir ) ) { $ this -> oLog -> dir = DEPLOY_LOG_DIR . $ sDir ; } else { $ this -> oLog -> dir = DEPLOY_LOG_DIR ; } }
Set the log directory which is being written to
227,342
public function prepare ( $ sQuery ) { if ( empty ( $ this -> oDb ) ) { $ this -> connect ( ) ; } return $ this -> oDb -> prepare ( $ sQuery ) ; }
Prepares an SQL query
227,343
public function escape ( $ sString ) { if ( empty ( $ this -> oDb ) ) { $ this -> connect ( ) ; } return $ this -> oDb -> quote ( $ sString ) ; }
Escapes a string to make it query safe
227,344
public function transactionStart ( ) { if ( empty ( $ this -> oDb ) ) { $ this -> connect ( ) ; } try { $ this -> oDb -> beginTransaction ( ) ; $ this -> transactionRunning = true ; return true ; } catch ( \ Exception $ e ) { throw new TransactionException ( $ e -> getMessage ( ) , $ e -> getCode ( ) ) ; } }
Starts a DB transaction
227,345
public function transactionCommit ( ) { if ( empty ( $ this -> oDb ) ) { $ this -> connect ( ) ; } try { $ this -> oDb -> commit ( ) ; $ this -> transactionRunning = false ; return true ; } catch ( \ Exception $ e ) { throw new TransactionException ( $ e -> getMessage ( ) , $ e -> getCode ( ) ) ; } }
Commits a DB transaction
227,346
public function transactionRollback ( ) { if ( empty ( $ this -> oDb ) ) { $ this -> connect ( ) ; } try { $ this -> oDb -> rollback ( ) ; $ this -> transactionRunning = false ; return true ; } catch ( \ Exception $ e ) { throw new TransactionException ( $ e -> getMessage ( ) , $ e -> getCode ( ) ) ; } }
Rollsback a DB transaction
227,347
public static function replaceLastOccurrence ( $ sString , $ sReplace , $ sSubject ) { $ iPos = strrpos ( $ sSubject , $ sString ) ; if ( $ iPos !== false ) { $ sSubject = substr_replace ( $ sSubject , $ sReplace , $ iPos , strlen ( $ sString ) ) ; } return $ sSubject ; }
Replace the last occurrence of a string within a string with a string
227,348
public static function underscoreToCamelcase ( $ sString , $ bLowerFirst = true ) { $ sString = explode ( '_' , $ sString ) ; $ sString = array_map ( 'strtolower' , $ sString ) ; $ sString = array_map ( 'ucfirst' , $ sString ) ; $ sString = implode ( $ sString ) ; $ sString = $ bLowerFirst ? lcfirst ( $ sString ) : $ s...
Transforms a string with underscores into a camelcased string
227,349
public static function generateToken ( $ sMask = null , $ aChars = [ ] , $ aDigits = [ ] ) { $ sMask = empty ( $ sMask ) ? 'AAAA-AAAA-AAAA-AAAA-AAAA-AAAA' : $ sMask ; $ aChars = empty ( $ aChars ) ? str_split ( 'abcdefghijklmnopqrstuvwxyz' ) : $ aChars ; $ aDigits = empty ( $ aDigits ) ? str_split ( '0123456789' ) : $ ...
Generates a token string using a specific mask
227,350
public static function prosaicList ( array $ aArray , $ sSeparator = ', ' , $ sConjunctive = ' and ' , $ bOxfordComma = true ) { $ iCount = count ( $ aArray ) ; if ( $ iCount <= 1 ) { return implode ( '' , $ aArray ) ; } elseif ( $ iCount == 2 ) { return implode ( $ sConjunctive , $ aArray ) ; } else { $ aOut = [ ] ; f...
Takes an array of strings and returns as a comma separated string using a terminal conjunctive optionally using an Oxford Comma .
227,351
public function getInstance ( $ sSlug ) { if ( isset ( $ this -> aInstances [ $ sSlug ] ) ) { return $ this -> aInstances [ $ sSlug ] ; } else { foreach ( $ this -> aComponents as $ oDriverConfig ) { if ( $ sSlug == $ oDriverConfig -> slug ) { $ oDriver = $ oDriverConfig ; break ; } } if ( ! empty ( $ oDriver ) ) { $ t...
Return an instance of the driver .
227,352
public function getContentName ( $ contentId ) : string { try { $ versionInfo = $ this -> loadVersionInfo ( $ contentId ) ; return $ versionInfo -> getName ( ) ?? '' ; } catch ( Throwable $ t ) { return '' ; } }
Returns the content name .
227,353
public function getLocationPath ( $ locationId ) : array { try { $ location = $ this -> loadLocation ( $ locationId ) ; $ locationPath = $ location -> path ; array_shift ( $ locationPath ) ; $ translatedNames = [ ] ; foreach ( $ locationPath as $ locationPathId ) { $ locationInPath = $ this -> loadLocation ( $ location...
Returns the location path .
227,354
public function getContentTypeName ( string $ identifier ) : string { try { $ contentType = $ this -> loadContentType ( $ identifier ) ; return $ contentType -> getName ( ) ?? '' ; } catch ( Throwable $ t ) { return '' ; } }
Returns the content type name .
227,355
private function loadVersionInfo ( $ contentId ) : VersionInfo { return $ this -> repository -> sudo ( static function ( Repository $ repository ) use ( $ contentId ) : VersionInfo { return $ repository -> getContentService ( ) -> loadVersionInfoById ( $ contentId ) ; } ) ; }
Loads the version info for provided content ID .
227,356
private function loadContentType ( string $ identifier ) : ContentType { return $ this -> repository -> sudo ( static function ( Repository $ repository ) use ( $ identifier ) : ContentType { return $ repository -> getContentTypeService ( ) -> loadContentTypeByIdentifier ( $ identifier ) ; } ) ; }
Loads the content type for provided identifier .
227,357
public static function get ( ) { if ( empty ( static :: $ sEnvironment ) ) { if ( ! empty ( $ _ENV [ 'ENVIRONMENT' ] ) ) { static :: set ( $ _ENV [ 'ENVIRONMENT' ] ) ; } else { static :: set ( ENVIRONMENT ) ; } try { $ oInput = Factory :: service ( 'Input' ) ; if ( static :: not ( static :: ENV_PROD ) && $ oInput -> he...
Get the current environment
227,358
public static function is ( $ mEnvironment ) { if ( is_array ( $ mEnvironment ) ) { return array_search ( static :: get ( ) , array_map ( 'strtoupper' , $ mEnvironment ) ) !== false ; } else { return static :: get ( ) === strtoupper ( $ mEnvironment ) ; } }
Returns whether the environment is the supplied environment
227,359
public function filter_uri ( & $ str ) { try { parent :: filter_uri ( $ str ) ; } catch ( Exception $ e ) { $ sMessage = 'The URI you submitted has disallowed characters.' ; if ( Environment :: is ( Environment :: ENV_PROD ) && $ e -> getMessage ( ) === $ sMessage ) { ErrorHandler :: halt ( $ sMessage , '' , HttpCodes ...
Filters the URI and prevents illegal characters
227,360
public function query ( $ sQuery ) { $ sQuery = $ this -> replaceConstants ( $ sQuery ) ; $ this -> iQueryCount ++ ; $ this -> sLastQuery = $ sQuery ; return $ this -> oDb -> query ( $ sQuery ) ; }
Execute a DB query
227,361
public function prepare ( $ sQuery ) { $ sQuery = $ this -> replaceConstants ( $ sQuery ) ; $ this -> iQueryCount ++ ; $ this -> sLastQuery = $ sQuery ; return $ this -> oDb -> prepare ( $ sQuery ) ; }
Prepare a DB query
227,362
protected function parseUrl ( string $ sUrl ) : \ stdClass { preg_match ( $ this -> oLocaleService -> getUrlRegex ( ) , $ sUrl , $ aMatches ) ; $ sLanguage = ! empty ( $ aMatches [ 1 ] ) ? $ aMatches [ 1 ] : '' ; $ sRequestUrl = ! empty ( $ aMatches [ 3 ] ) ? $ aMatches [ 3 ] : '' ; $ aRequestUrl = parse_url ( $ sReque...
Parse the URL for supported languages
227,363
public function getData ( $ sKey = null ) { if ( is_null ( $ sKey ) ) { return $ this -> aData ; } elseif ( array_key_exists ( $ sKey , $ this -> aData ) ) { return $ this -> aData [ $ sKey ] ; } else { return null ; } }
Get an item from the view data array
227,364
public function setData ( $ mKey , $ mValue = null ) { if ( is_array ( $ mKey ) ) { foreach ( $ mKey as $ sKey => $ mSubValue ) { $ this -> setData ( $ sKey , $ mSubValue ) ; } } elseif ( is_string ( $ mKey ) || is_numeric ( $ mKey ) ) { $ this -> aData [ $ mKey ] = $ mValue ; } else { throw new NailsException ( 'Key m...
Add an item to the view data array or update an existing item
227,365
public function unsetData ( $ mKey ) { if ( is_array ( $ mKey ) ) { foreach ( $ mKey as $ sSubKey ) { $ this -> unsetData ( $ sSubKey ) ; } } else { unset ( $ this -> aData [ $ mKey ] ) ; } return $ this ; }
Unset an item from the view data array
227,366
protected function resolvePath ( $ sView ) { $ sCacheKey = 'path:' . $ sView ; $ sCached = $ this -> getCache ( $ sCacheKey ) ; if ( $ sCached !== null ) { return $ sCached ; } $ sView = preg_replace ( '/\.php$/' , '' , $ sView ) . '.php' ; $ sResolvedPath = '' ; $ oRouter = Factory :: service ( 'Router' ) ; if ( strpo...
Attempts to resolve the view path
227,367
public function isLoaded ( string $ sView ) : bool { try { return array_key_exists ( $ this -> resolvePath ( $ sView ) , $ this -> aLoadedViews ) ; } catch ( ViewNotFoundException $ e ) { return false ; } }
Determines if a view has previous been loaded or not
227,368
function defineAppVars ( ) { $ vars = [ ] ; $ vars [ ] = '// App Constants' ; $ vars [ ] = [ 'key' => 'APP_NAME' , 'label' => 'App Name' , 'value' => defined ( 'APP_NAME' ) ? APP_NAME : 'Untitled' , ] ; $ vars [ ] = [ 'key' => 'APP_DEFAULT_TIMEZONE' , 'label' => 'App Timezone' , 'value' => defined ( 'APP_DEFAULT_TIMEZO...
Defines all the App vars and their defaults
227,369
private function defineDeployVars ( ) { $ vars = [ ] ; $ vars [ ] = [ 'key' => 'ENVIRONMENT' , 'label' => 'Environment' , 'value' => Environment :: get ( ) ? : Environment :: ENV_DEV , 'options' => Environment :: available ( ) , 'callback' => function ( $ sInput ) { return trim ( strtoupper ( $ sInput ) ) ; } , ] ; $ v...
Defines all the Deploy vars and their defaults
227,370
private function getVarValue ( $ sKey , $ aVars ) { foreach ( $ aVars as $ aVar ) { if ( $ sKey == $ aVar [ 'key' ] ) { return $ aVar [ 'value' ] ; } } return null ; }
Returns the current value of a variable
227,371
private function getConstantsFromFile ( $ path , array $ vars = [ ] ) { $ out = [ ] ; if ( file_exists ( $ path ) ) { $ appFile = file_get_contents ( $ path ) ; $ pattern = '/define\([\'|"](.+?)[\'|"]\,(.*)\)/' ; preg_match_all ( $ pattern , $ appFile , $ matches ) ; if ( ! empty ( $ matches [ 0 ] ) ) { $ numMatches = ...
Finds all constants defined in a particular file
227,372
private function setVars ( & $ vars ) { foreach ( $ vars as & $ v ) { if ( is_array ( $ v ) ) { $ question = 'What should "' . $ v [ 'label' ] . '" be set to?' ; if ( ! empty ( $ v [ 'options' ] ) ) { $ question .= ' (' . implode ( '|' , $ v [ 'options' ] ) . ')' ; do { $ v [ 'value' ] = $ this -> ask ( $ question , $ ...
Requests the user to confirm all the variables
227,373
private function writeFile ( $ vars , $ file ) { $ fp = fopen ( $ file , 'w' ) ; fwrite ( $ fp , "<?php\n" ) ; foreach ( $ vars as $ v ) { if ( is_string ( $ v ) ) { fwrite ( $ fp , $ v . "\n" ) ; } else { if ( is_numeric ( $ v [ 'value' ] ) ) { $ sValue = $ v [ 'value' ] ; } else { $ sValue = "'" . str_replace ( "'" ,...
Writes the supplied variables to the config file
227,374
private function migrateDb ( $ sDbHost = null , $ sDbUser = null , $ sDbPass = null , $ sDbName = null ) { $ iExitCode = $ this -> callCommand ( 'db:migrate' , [ '--dbHost' => $ sDbHost , '--dbUser' => $ sDbUser , '--dbPass' => $ sDbPass , '--dbName' => $ sDbName , ] , false , true ) ; if ( $ iExitCode == static :: EXI...
Migrates the DB for a fresh install
227,375
private function buildSortParameters ( ParameterBuilderInterface $ builder , array $ groups = [ ] , array $ allowedSortTypes = [ ] ) : void { $ sortTypes = [ 'Published' => 'date_published' , 'Modified' => 'date_modified' , 'Alphabetical' => 'content_name' , 'Priority' => 'location_priority' , 'Defined by parent' => 'd...
Builds the parameters for sorting eZ content .
227,376
private function getSortClauses ( ParameterCollectionInterface $ parameterCollection , ? Location $ parentLocation = null ) : array { $ sortType = $ parameterCollection -> getParameter ( 'sort_type' ) -> getValue ( ) ?? 'default' ; $ sortDirection = $ parameterCollection -> getParameter ( 'sort_direction' ) -> getValue...
Returns the clauses for sorting eZ content .
227,377
public function view ( $ sSlug , $ sView , $ aData = array ( ) , $ bReturn = false ) { $ aSkins = $ this -> getAll ( ) ; $ oSkin = null ; foreach ( $ aSkins as $ oSkinConfig ) { if ( $ oSkinConfig -> slug == $ sSlug ) { $ oSkin = $ oSkinConfig ; break ; } } if ( empty ( $ oSkin ) ) { throw new NailsException ( '"' . $ ...
Load a view contained within a skin
227,378
public function getAllFlat ( ) { $ aOut = array ( ) ; $ aCountries = $ this -> getAll ( ) ; foreach ( $ aCountries as $ oCountry ) { $ aOut [ $ oCountry -> code ] = $ oCountry -> label ; } return $ aOut ; }
Get all defined countries as a flat array
227,379
public function getByCode ( $ sCode ) { $ aCountries = $ this -> getAll ( ) ; return ! empty ( $ aCountries [ $ sCode ] ) ? $ aCountries [ $ sCode ] : false ; }
Get a country by it s code
227,380
public function getContinentByCode ( $ sCode ) { $ aContinents = $ this -> getAll ( ) ; return ! empty ( $ aContinents [ $ sCode ] ) ? $ aContinents [ $ sCode ] : false ; }
Get a continent by it s code
227,381
public function getLogoUrl ( $ iWidth = null , $ iHeight = null ) { $ iLogoId = $ this -> getLogoId ( ) ; if ( ! empty ( $ iLogoId ) && ! empty ( $ iWidth ) && ! empty ( $ iHeight ) ) { return cdnScale ( $ iLogoId , $ iWidth , $ iHeight ) ; } elseif ( ! empty ( $ iLogoId ) ) { return cdnServe ( $ iLogoId ) ; } else { r...
Returns the URL of the driver s logo
227,382
public function getEnabledSlug ( ) { if ( $ this -> bEnableMultiple ) { $ aOut = [ ] ; foreach ( $ this -> mEnabled as $ oComponent ) { $ aOut [ ] = $ oComponent -> slug ; } return $ aOut ; } else { return ! empty ( $ this -> mEnabled -> slug ) ? $ this -> mEnabled -> slug : null ; } }
Fetches the slug of the enabled components or array of slugs if bEnableMultiple is true
227,383
public function getBySlug ( $ sSlug ) { foreach ( $ this -> aComponents as $ oComponent ) { if ( $ sSlug == $ oComponent -> slug ) { return $ oComponent ; } } return null ; }
Get a component by it s slug
227,384
public function saveEnabled ( $ mSlug ) { $ oAppSettingService = Factory :: service ( 'AppSetting' ) ; if ( $ this -> bEnableMultiple ) { $ mSlug = ( array ) $ mSlug ; $ mSlug = array_filter ( $ mSlug ) ; $ mSlug = array_unique ( $ mSlug ) ; } else { $ mSlug = trim ( $ mSlug ) ; } $ aSetting = [ $ this -> sEnabledSetti...
Save which components are enabled
227,385
protected function extractComponentSettings ( $ aSettings , $ sSlug ) { $ aOut = [ ] ; foreach ( $ aSettings as $ oSetting ) { if ( isset ( $ oSetting -> fields ) ) { $ aOut = array_merge ( $ aOut , $ this -> extractComponentSettings ( $ oSetting -> fields , $ sSlug ) ) ; } else { $ sValue = appSetting ( $ oSetting -> ...
Recursively gets all the settings from the settings array
227,386
protected function loremWord ( $ iNumWords = 5 ) { $ aWords = [ 'lorem' , 'ipsum' , 'dolor' , 'sit' , 'amet' , 'consectetur' , 'adipiscing' , 'elit' , 'mauris' , 'venenatis' , 'metus' , 'volutpat' , 'hendrerit' , 'interdum' , 'nisi' , 'odio' , 'finibus' , 'ex' , 'eu' , 'congue' , 'mauris' , 'nisi' , 'in' , 'magna' , 'u...
Generate some random Lorem Ipsum words
227,387
protected function loremSentence ( $ iNumSentences = 1 ) { $ aOut = [ ] ; $ aLengths = [ 5 , 6 , 8 , 10 , 12 ] ; for ( $ i = 0 ; $ i < $ iNumSentences ; $ i ++ ) { $ iLength = $ aLengths [ array_rand ( $ aLengths ) ] ; $ aOut [ ] = ucfirst ( $ this -> loremWord ( $ iLength ) ) ; } return implode ( '. ' , $ aOut ) . '.'...
Generate some random Lorem Ipsum sentences
227,388
protected function loremParagraph ( $ iNumParagraphs = 1 ) { $ aOut = [ ] ; $ aLengths = [ 5 , 6 , 8 , 10 , 12 ] ; for ( $ i = 0 ; $ i < $ iNumParagraphs ; $ i ++ ) { $ iLength = $ aLengths [ array_rand ( $ aLengths ) ] ; $ aOut [ ] = $ this -> loremSentence ( $ iLength ) ; } return implode ( "\n\n" , $ aOut ) ; }
Generate some random Lorem Ipsum paragraphs
227,389
protected function randomId ( $ sModel , $ sProvider , $ aData = [ ] ) { $ oModel = Factory :: model ( $ sModel , $ sProvider ) ; $ aResults = $ oModel -> getAll ( 0 , 1 , $ aData + [ 'sort' => [ [ 'id' , 'random' ] ] ] ) ; $ oRow = reset ( $ aResults ) ; return $ oRow ? $ oRow -> id : null ; }
Returns a random ID from a particular model
227,390
protected function randomPastDateTime ( $ sLow = null ) { $ oNow = Factory :: factory ( 'DateTime' ) ; return $ this -> randomDateTime ( $ sLow , $ oNow -> format ( 'Y-m-d H:i:s' ) ) ; }
Return a random datetime from the past optionally restricted to a lower bound
227,391
protected function randomDate ( $ sLow = null , $ sHigh = null , $ sFormat = 'Y-m-d' ) { $ iLow = $ sLow ? strtotime ( $ sLow ) : strtotime ( 'last year' ) ; $ iHigh = $ sHigh ? strtotime ( $ sHigh ) : strtotime ( 'next year' ) ; return date ( $ sFormat , rand ( $ iLow , $ iHigh ) ) ; }
Return a random date optionally restricted between bounds
227,392
protected function randomFutureDate ( $ sHigh = null ) { $ oNow = Factory :: factory ( 'DateTime' ) ; return $ this -> randomDateTime ( $ oNow -> format ( 'Y-m-d' ) , $ sHigh ) ; }
Return a random date from the future optionally restricted to a upper bound
227,393
private function prepareModelName ( $ sModelName ) : \ stdClass { $ sModelName = preg_replace ( '/[^a-zA-Z\/ ]/' , '' , $ sModelName ) ; $ sModelName = preg_replace ( '/\//' , ' \\ ' , $ sModelName ) ; $ sModelName = ucwords ( $ sModelName ) ; $ sTableName = preg_replace ( '/[^a-z ]/' , '' , strtolower ( $ sModelName )...
Prepare the model details and do some preliminary checks
227,394
private function tableExists ( \ stdClass $ oModel ) : bool { $ oDb = Factory :: service ( 'PDODatabase' ) ; $ oResult = $ oDb -> query ( 'SHOW TABLES LIKE "' . $ oModel -> table_with_prefix . '"' ) ; return $ oResult -> rowCount ( ) > 0 ; }
Detemine whether a particular table exists already
227,395
private function convertExistingModelToLocalised ( \ stdClass $ oModel , bool $ bSkipDb , bool $ bAdmin , bool $ bSkipSeeder ) : void { $ this -> addLocalisedUseStatement ( $ oModel ) -> convertTablesToLocalised ( $ oModel ) ; }
Orchestrates the conversion of a normal model to a localised model
227,396
private function createLocalisedModel ( \ stdClass $ oModel , bool $ bSkipDb , bool $ bAdmin , bool $ bSkipSeeder ) : array { $ this -> createModelFile ( $ oModel , 'model_localised' ) -> createResource ( $ oModel , 'resource' ) ; if ( ! $ bSkipDb ) { $ this -> createDatabaseTable ( $ oModel , 'model_table_localised' )...
Orchestrates the creation of a localised model
227,397
private function createModelFile ( \ stdClass $ oModel , string $ sTemplate ) : self { $ this -> oOutput -> write ( 'Creating model <comment>' . $ oModel -> class_path . '</comment>... ' ) ; $ this -> createPath ( $ oModel -> path ) ; $ this -> createFile ( $ oModel -> path . $ oModel -> filename , $ this -> getResourc...
Creates the model file
227,398
private function createResource ( \ stdClass $ oModel , string $ sTemplate ) : self { $ this -> oOutput -> write ( 'Creating resource <comment>' . $ oModel -> resource_class_path . '</comment>... ' ) ; $ this -> createPath ( $ oModel -> resource_path ) ; $ this -> createFile ( $ oModel -> resource_path . $ oModel -> re...
Creates the resource file
227,399
private function createDatabaseTable ( \ stdClass $ oModel , string $ sTemplate ) : self { $ this -> oOutput -> write ( 'Adding database table... ' ) ; $ oModel -> nails_db_prefix = NAILS_DB_PREFIX ; $ oDb = Factory :: service ( 'PDODatabase' ) ; $ oDb -> query ( $ this -> getResource ( 'template/' . $ sTemplate . '.ph...
Creates the database table