idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
227,100
private function isInteger ( $ float , $ allowIntegers ) { if ( ! $ allowIntegers || round ( $ float ) !== $ float ) { return false ; } elseif ( abs ( $ float ) < self :: FLOAT_MAX ) { return true ; } return $ allowIntegers === 'all' ; }
Tells if the number can be encoded as an integer .
227,101
private function encodeInteger ( $ float , callable $ encode ) { $ minimum = \ defined ( 'PHP_INT_MIN' ) ? \ PHP_INT_MIN : ~ \ PHP_INT_MAX ; if ( $ float >= $ minimum && $ float <= \ PHP_INT_MAX ) { return $ encode ( ( int ) $ float ) ; } return number_format ( $ float , 0 , '.' , '' ) ; }
Encodes the given float as an integer .
227,102
private function determinePrecision ( $ options ) { $ precision = $ options [ 'float.precision' ] ; if ( $ precision === false ) { $ precision = ini_get ( 'serialize_precision' ) ; } return max ( 1 , ( int ) $ precision ) ; }
Determines the float precision based on the options .
227,103
private function encodeFloat ( $ float , $ precision ) { $ log = ( int ) floor ( log ( abs ( $ float ) , 10 ) ) ; if ( $ log > - 5 && abs ( $ float ) < self :: FLOAT_MAX && abs ( $ log ) < $ precision ) { return $ this -> formatFloat ( $ float , $ precision - $ log - 1 ) ; } $ log += ( int ) ( round ( abs ( $ float ) /...
Encodes the number using a floating point representation .
227,104
private function formatFloat ( $ float , $ digits ) { $ digits = max ( ( int ) $ digits , 1 ) ; $ string = rtrim ( number_format ( $ float , $ digits , '.' , '' ) , '0' ) ; return substr ( $ string , - 1 ) === '.' ? $ string . '0' : $ string ; }
Formats the number as a decimal number .
227,105
public function getMultiLevelDropdownWrapper ( MenuItem $ item ) : string { return '<li class="treeview' . ( $ item -> hasActiveOnChild ( ) ? ' active' : '' ) . '"> <a href="#"> ' . ( $ item -> icon ? '<i class="' . $ item -> icon . '"></i>' : '' ) . ' <s...
Get multilevel menu wrapper .
227,106
public function update ( AccountPasswordRequest $ request ) { $ currentUser = $ request -> user ( $ this -> getGuard ( ) ) ; $ currentUser -> fill ( [ 'password' => $ request -> get ( 'new_password' ) ] ) -> forceSave ( ) ; return intend ( [ 'back' => true , 'with' => [ 'success' => trans ( 'cortex/auth::messages.accou...
Update account password .
227,107
protected static function parse ( \ ReflectionClass $ oReflectionClass ) { $ sContent = file_get_contents ( $ oReflectionClass -> getFileName ( ) ) ; $ aTokens = token_get_all ( $ sContent ) ; $ sDocComment = null ; $ bIsConst = false ; foreach ( $ aTokens as $ aToken ) { if ( ! is_array ( $ aToken ) || count ( $ aToke...
Parses a class for constants and DocComments
227,108
public static function getEventNamespace ( ) { $ oComponent = Components :: detectClassComponent ( get_called_class ( ) ) ; if ( empty ( $ oComponent ) ) { throw new NailsException ( 'Could not detect class\' component' ) ; } return $ oComponent -> slug ; }
Calculates the event s namespace
227,109
public static function info ( ) { $ oReflectionClass = new \ ReflectionClass ( get_called_class ( ) ) ; static :: parse ( $ oReflectionClass ) ; $ aOut = [ ] ; foreach ( $ oReflectionClass -> getConstants ( ) as $ sConstant => $ sValue ) { $ aOut [ $ sConstant ] = ( object ) [ 'constant' => get_called_class ( ) . '::' ...
Returns an array of the available events with supporting information
227,110
public function setHeader ( $ sHeader , $ mValue ) { if ( empty ( $ this -> aHeaders ) ) { $ this -> aHeaders = [ ] ; } $ this -> aHeaders [ $ sHeader ] = $ mValue ; return $ this ; }
Sets a header
227,111
public function getHeader ( $ sHeader ) { return isset ( $ this -> aHeaders [ $ sHeader ] ) ? $ this -> aHeaders [ $ sHeader ] : null ; }
Returns a single header
227,112
public function asUser ( $ iUserId ) { return $ this -> setHeader ( Testing :: TEST_HEADER_NAME , Testing :: TEST_HEADER_VALUE ) -> setHeader ( Testing :: TEST_HEADER_USER_NAME , $ iUserId ) ; }
Set the required headers for imitating a user
227,113
public function execute ( ) { $ aClientConfig = [ 'base_uri' => $ this -> sBaseUri , 'verify' => ! ( Environment :: is ( Environment :: ENV_DEV ) || Environment :: is ( Environment :: ENV_TEST ) ) , 'allow_redirects' => Environment :: not ( Environment :: ENV_TEST ) , 'http_errors' => Environment :: not ( Environment :...
Configures and executes the HTTP request
227,114
public function detect ( ) : \ Nails \ Common \ Factory \ Locale { $ oLocale = $ this -> getDefautLocale ( ) ; if ( static :: ENABLE_SNIFF ) { if ( static :: ENABLE_SNIFF_HEADER ) { $ this -> sniffHeader ( $ oLocale ) ; } if ( static :: ENABLE_SNIFF_USER ) { $ this -> sniffActiveUser ( $ oLocale ) ; } if ( static :: EN...
Attempts to detect the locale from the request
227,115
public function sniffLocale ( \ Nails \ Common \ Factory \ Locale $ oLocale = null ) : \ Nails \ Common \ Factory \ Locale { if ( ! $ oLocale ) { $ oLocale = $ this -> getDefautLocale ( ) ; } $ this -> sniffHeader ( $ oLocale ) -> sniffActiveUser ( $ oLocale ) -> sniffUrl ( $ oLocale ) -> sniffCookie ( $ oLocale ) -> s...
Sniff various items to determine the user s locale
227,116
public function sniffQuery ( \ Nails \ Common \ Factory \ Locale & $ oLocale ) { $ this -> setFromString ( $ oLocale , $ this -> oInput -> get ( static :: QUERY_PARAM ) ?? null ) ; return $ this ; }
Looks for a locale in the query string and updates the locale object
227,117
public static function parseLocaleString ( ? string $ sLocale ) : array { return [ \ Locale :: getPrimaryLanguage ( $ sLocale ) , \ Locale :: getRegion ( $ sLocale ) , \ Locale :: getScript ( $ sLocale ) , ] ; }
Parses a locale string into it s respective framgments
227,118
public function set ( \ Nails \ Common \ Factory \ Locale $ oLocale = null ) : self { $ this -> oLocale = $ oLocale ; return $ this ; }
Manually sets a locale
227,119
public function getDefautLocale ( ) : \ Nails \ Common \ Factory \ Locale { return Factory :: factory ( 'Locale' ) -> setLanguage ( Factory :: factory ( 'LocaleLanguage' , null , static :: DEFAULT_LANGUAGE ) ) -> setRegion ( Factory :: factory ( 'LocaleRegion' , null , static :: DEFAULT_REGION ) ) -> setScript ( Factor...
Returns the default locale to use for the system
227,120
public function isSupportedLocale ( \ Nails \ Common \ Factory \ Locale $ oLocale ) : bool { return in_array ( $ oLocale , $ this -> getSupportedLocales ( ) ) ; }
Returns whetehr the supplied locale is supported or not
227,121
public function getUrlRegex ( ) : string { $ aSupportedLocales = $ this -> getSupportedLocales ( ) ; $ aUrlLocales = [ ] ; foreach ( $ aSupportedLocales as $ oLocale ) { $ sVanity = $ this -> getUrlSegment ( $ oLocale ) ; $ aUrlLocales [ ] = $ sVanity ; } return '/^(' . implode ( '|' , array_filter ( $ aUrlLocales ) ) ...
Returns a regex suitable for detecting a language flag at the beginning of the URL
227,122
public static function flagEmoji ( \ Nails \ Common \ Factory \ Locale $ oLocale ) : string { $ sRegion = $ oLocale -> getRegion ( ) ; $ aCountries = json_decode ( file_get_contents ( NAILS_APP_PATH . 'vendor/annexare/countries-list/dist/countries.emoji.json' ) ) ; return ! empty ( $ aCountries -> { $ sRegion } -> emoj...
Returns an emoji flag for a locale
227,123
public function getUrlSegment ( \ Nails \ Common \ Factory \ Locale $ oLocale ) : string { if ( $ oLocale == $ this -> getDefautLocale ( ) ) { return '' ; } else { return getFromArray ( ( string ) $ oLocale , static :: URL_VANITY_MAP , ( string ) $ oLocale ) ; } }
Returns the URL prefix for a given locale considering any vanity preferences
227,124
public static function encode ( $ mValue , $ sSalt = '' ) { try { return Crypto :: encryptWithPassword ( $ mValue , static :: getKey ( $ sSalt ) ) ; } catch ( EnvironmentIsBrokenException $ e ) { throw new EnvironmentException ( $ e -> getMessage ( ) , $ e -> getCode ( ) ) ; } }
Encodes a given value using the supplied key
227,125
public static function decode ( $ sCipher , $ sSalt = '' ) { try { return Crypto :: decryptWithPassword ( $ sCipher , static :: getKey ( $ sSalt ) ) ; } catch ( EnvironmentIsBrokenException $ e ) { throw new EnvironmentException ( $ e -> getMessage ( ) , $ e -> getCode ( ) ) ; } catch ( WrongKeyOrModifiedCiphertextExce...
Decodes a given value using the supplied key
227,126
public static function migrate ( $ sCipher , $ sOldKey , $ sNewSalt = '' ) { require_once NAILS_CI_SYSTEM_PATH . 'libraries/Encrypt.php' ; $ oEncryptCi = new \ CI_Encrypt ( ) ; $ oEncrypt = Factory :: service ( 'Encrypt' ) ; return $ oEncrypt :: encode ( $ oEncryptCi -> decode ( $ sCipher , $ sOldKey ) , $ sNewSalt ) ;...
Migrates a cipher from CI encrypt library to Defuse \ Crypto library
227,127
public static function isValidIp ( $ sIp , $ sType = null ) { switch ( strtoupper ( $ sType ) ) { case 'IPV4' : return filter_var ( $ sIp , FILTER_VALIDATE_IP , FILTER_FLAG_IPV4 ) ; break ; case 'IPV6' : return filter_var ( $ sIp , FILTER_VALIDATE_IP , FILTER_FLAG_IPV6 ) ; break ; default : return filter_var ( $ sIp , ...
Validate an IP address
227,128
private function getContentType ( Content $ content ) : EzContentType { if ( method_exists ( $ content , 'getContentType' ) ) { return $ content -> getContentType ( ) ; } return $ this -> contentTypeService -> loadContentType ( $ content -> contentInfo -> contentTypeId ) ; }
Loads the content type for provided content .
227,129
private function createSeeder ( ) : void { $ aFields = $ this -> getArguments ( ) ; $ aCreated = [ ] ; try { $ aModels = array_filter ( explode ( ',' , $ aFields [ 'MODEL_NAME' ] ) ) ; sort ( $ aModels ) ; foreach ( $ aModels as $ sModel ) { $ aFields [ 'MODEL_NAME' ] = $ sModel ; $ this -> oOutput -> write ( 'Creating...
Create the Seeder
227,130
private function createEventListener ( ) : self { $ aFields = $ this -> getArguments ( ) ; $ aCreated = [ ] ; try { $ aToCreate = [ ] ; $ aListeners = array_filter ( array_map ( function ( $ sListener ) { return implode ( '/' , array_map ( 'ucfirst' , explode ( '/' , ucfirst ( trim ( $ sListener ) ) ) ) ) ; } , explode...
Create the Listener
227,131
protected function generateFilePath ( array $ aServiceBits ) : string { $ sClassName = array_pop ( $ aServiceBits ) ; return implode ( DIRECTORY_SEPARATOR , array_map ( function ( $ sItem ) { return rtrim ( $ sItem , DIRECTORY_SEPARATOR ) ; } , array_merge ( [ static :: APP_PATH ] , $ aServiceBits , [ $ sClassName . '....
Generate the class file path
227,132
public function display_error ( $ error = '' , $ swap = '' , $ native = false ) { if ( is_array ( $ error ) ) { $ error = implode ( '; ' , $ error ) ; } throw new QueryException ( $ error ) ; }
Display an error message using an exception rather than a view
227,133
protected function _compile_join ( ) { $ sSql = '' ; if ( count ( $ this -> qb_join ) > 0 ) { $ sSql .= "\n" . implode ( "\n" , $ this -> qb_join ) ; } return $ sSql ; }
Compiles the JOIN string
227,134
protected function determineModuleState ( $ sModuleName , $ sMigrationsPath ) : ? \ stdClass { $ oModule = ( object ) [ 'name' => $ sModuleName , 'start' => null , 'end' => null , ] ; $ aDirMap = $ this -> mapDir ( $ sMigrationsPath ) ; if ( ! empty ( $ aDirMap ) ) { $ aMigrations = [ ] ; foreach ( $ aDirMap as $ dir )...
Determines whether or not the module needs to migration and if so between what versions
227,135
protected function findEnabledModules ( ) : array { $ aModules = Components :: available ( false ) ; $ aOut = [ ] ; foreach ( $ aModules as $ oModule ) { $ aOut [ ] = $ this -> determineModuleState ( $ oModule -> slug , $ oModule -> path . 'migrations/' ) ; } return array_filter ( $ aOut ) ; }
Looks for enabled Nails modules which support migration
227,136
protected function doMigration ( $ oModule ) : bool { $ oOutput = $ this -> oOutput ; $ sPath = $ oModule -> name == 'APP' ? 'application/migrations/' : 'vendor/' . $ oModule -> name . '/migrations/' ; $ aDirMap = $ this -> mapDir ( $ sPath ) ; $ iCurrent = is_null ( $ oModule -> start ) ? - 1 : $ oModule -> start ; fo...
Executes a migration
227,137
private function executeMigration ( $ oModule , $ aMigration ) : bool { $ oOutput = $ this -> oOutput ; require_once $ aMigration [ 'path' ] ; $ sPattern = '[^a-zA-Z0-9' . preg_quote ( DIRECTORY_SEPARATOR , '/\-' ) . ']' ; $ sModuleName = strtolower ( $ oModule -> name ) ; $ sModuleName = preg_replace ( '/' . $ sPatter...
Executes an individual migration
227,138
private function mapDir ( $ sDir ) : ? array { if ( is_dir ( $ sDir ) ) { $ aOut = [ ] ; foreach ( new \ DirectoryIterator ( $ sDir ) as $ oFileInfo ) { if ( $ oFileInfo -> isDot ( ) ) { continue ; } if ( preg_match ( static :: VALID_MIGRATION_PATTERN , $ oFileInfo -> getFilename ( ) , $ aMatches ) ) { $ aOut [ $ aMatc...
Generates an array of files in a directory
227,139
private function buildContentTypeFilterParameters ( ParameterBuilderInterface $ builder , array $ groups = [ ] ) : void { $ builder -> add ( 'filter_by_content_type' , ParameterType \ Compound \ BooleanType :: class , [ 'groups' => $ groups , ] ) ; $ builder -> get ( 'filter_by_content_type' ) -> add ( 'content_types' ...
Builds the parameters for filtering by content types .
227,140
private function getContentTypeFilterCriteria ( ParameterCollectionInterface $ parameterCollection ) : ? Criterion { if ( $ parameterCollection -> getParameter ( 'filter_by_content_type' ) -> getValue ( ) !== true ) { return null ; } $ contentTypes = $ parameterCollection -> getParameter ( 'content_types' ) -> getValue...
Returns the criteria used to filter content by content type .
227,141
public function read ( string $ sKey ) : ? Resource \ Cookie { return ArrayHelper :: getFromArray ( $ sKey , $ this -> aCookies , null ) ; }
Returns a specific cookie
227,142
public function write ( string $ sKey , string $ sValue , int $ iTTL = null , string $ sPath = '' , string $ sDomain = '' , bool $ bSecure = false , bool $ bHttpOnly = false ) : bool { if ( setcookie ( $ sKey , $ sValue , $ iTTL ? time ( ) + $ iTTL : 0 , $ sPath , $ sDomain , $ bSecure , $ bHttpOnly ) ) { $ this -> aCo...
Writes a cookie or overwrites an existing one
227,143
public function view ( $ view , $ vars = [ ] , $ return = false ) { if ( strpos ( $ view , '/' ) === 0 ) { if ( substr ( $ view , strlen ( EXT ) * - 1 ) != EXT ) { $ view .= EXT ; } $ pathInfo = pathinfo ( $ view ) ; $ path = $ pathInfo [ 'dirname' ] . '/' ; $ view = $ pathInfo [ 'filename' ] ; $ this -> _ci_view_paths...
Loads a view . If an absolute path is provided then that view will be used otherwise the system will search the modules
227,144
public function viewExists ( $ view ) { list ( $ path , $ view ) = Modules :: find ( $ view , $ this -> _module , 'views/' ) ; return ( bool ) trim ( $ path ) ; }
Determines whether or not a view exists
227,145
public function getBody ( $ bIsJSON = true ) { if ( $ bIsJSON ) { return json_decode ( $ this -> oResponse -> getBody ( ) ) ; } else { return ( string ) $ this -> oResponse -> getBody ( ) ; } }
Return the response s body optionally parsed as JSON
227,146
public static function property ( string $ sPropertyName , ? string $ sComponentName = '' ) { $ mProperty = self :: getService ( 'properties' , $ sPropertyName , $ sComponentName ) ; if ( is_callable ( $ mProperty ) ) { return $ mProperty ( ) ; } else { return $ mProperty ; } }
Return a property from the container .
227,147
public static function setProperty ( string $ sPropertyName , $ mPropertyValue , ? string $ sComponentName = '' ) : void { $ sComponentName = empty ( $ sComponentName ) ? 'nails/common' : $ sComponentName ; if ( ! self :: $ aContainers [ $ sComponentName ] [ 'properties' ] -> offsetExists ( $ sPropertyName ) ) { throw ...
Sets a new value for a property
227,148
public static function service ( string $ sServiceName , ? string $ sComponentName = '' ) : object { return static :: getServiceOrModel ( static :: $ aLoadedItems [ 'SERVICES' ] , 'services' , $ sServiceName , $ sComponentName , array_slice ( func_get_args ( ) , 2 ) ) ; }
Return a service from the container .
227,149
public static function model ( string $ sModelName , ? string $ sComponentName = '' ) : Base { return static :: getServiceOrModel ( static :: $ aLoadedItems [ 'MODELS' ] , 'models' , $ sModelName , $ sComponentName , array_slice ( func_get_args ( ) , 2 ) ) ; }
Return a model from the container .
227,150
private static function getServiceOrModel ( array & $ aTrackerArray , string $ sType , string $ sName , string $ sComponent , array $ aParamaters ) : object { $ sKey = md5 ( $ sComponent . $ sName ) ; if ( ! array_key_exists ( $ sKey , $ aTrackerArray ) ) { $ aTrackerArray [ $ sKey ] = call_user_func_array ( self :: ge...
Loads a servie or a model from the tracker array
227,151
public static function factory ( string $ sFactoryName , ? string $ sComponentName = '' ) : object { return call_user_func_array ( self :: getService ( 'factories' , $ sFactoryName , $ sComponentName ) , array_slice ( func_get_args ( ) , 2 ) ) ; }
Return a factory from the container .
227,152
public static function resource ( string $ sResourceName , ? string $ sComponentName = '' ) : Resource { return call_user_func_array ( self :: getService ( 'resources' , $ sResourceName , $ sComponentName ) , array_slice ( func_get_args ( ) , 2 ) ) ; }
Return a resource from the container .
227,153
public static function helper ( string $ sHelperName , ? string $ sComponentName = '' ) : void { $ sComponentName = empty ( $ sComponentName ) ? 'nails/common' : $ sComponentName ; if ( empty ( self :: $ aLoadedHelpers [ $ sComponentName ] [ $ sHelperName ] ) ) { if ( empty ( self :: $ aLoadedHelpers [ $ sComponentName...
Load a helper file
227,154
private static function getService ( string $ sServiceType , string $ sServiceName , ? string $ sComponentName = '' ) { $ sComponentName = empty ( $ sComponentName ) ? 'nails/common' : $ sComponentName ; if ( ! array_key_exists ( $ sComponentName , self :: $ aContainers ) ) { throw new FactoryException ( 'No containers...
Returns a service from the namespaced container
227,155
public static function autoload ( ) : void { require_once BASEPATH . 'core/Common.php' ; $ aComponents = [ ] ; foreach ( Components :: available ( ) as $ oModule ) { $ aComponents [ ] = ( object ) [ 'slug' => $ oModule -> slug , 'autoload' => $ oModule -> autoload , ] ; } foreach ( $ aComponents as $ oModule ) { if ( !...
Auto - loads items at startup
227,156
protected static function extractAutoLoadItemsFromComposerJson ( string $ sPath ) : \ stdClass { $ oOut = ( object ) [ 'helpers' => [ ] , 'services' => [ ] ] ; if ( file_exists ( $ sPath ) ) { $ oAppComposer = json_decode ( file_get_contents ( $ sPath ) ) ; if ( ! empty ( $ oAppComposer -> extra -> nails -> autoload ->...
Extracts the autoload elements from a composer . json file
227,157
public static function destroyService ( string $ sServiceName , ? string $ sComponentName = '' ) : bool { return static :: destroyServiceOrModel ( static :: $ aLoadedItems [ 'SERVICES' ] , null , $ sServiceName , $ sComponentName ) ; }
Allows for a service to be destroyed so that a subsequent request will yeild a new instance
227,158
public static function destroyModel ( string $ sModelName , ? string $ sComponentName = '' ) : bool { return static :: destroyServiceOrModel ( static :: $ aLoadedItems [ 'MODELS' ] , null , $ sModelName , $ sComponentName ) ; }
Allows for a model to be destroyed so that a subsequent request will yeild a new instance
227,159
public static function destroy ( object $ oInstance ) : bool { foreach ( static :: $ aLoadedItems [ 'SERVICES' ] as $ sKey => $ oItem ) { if ( $ oItem === $ oInstance ) { return static :: destroyServiceOrModel ( static :: $ aLoadedItems [ 'SERVICES' ] , $ sKey ) ; } } foreach ( static :: $ aLoadedItems [ 'MODELS' ] as ...
Destroys an object by its instance
227,160
private static function destroyServiceOrModel ( array & $ aTrackerArray , string $ sKey , string $ sName = null , string $ sComponent = null ) : bool { if ( ! $ sKey ) { $ sKey = md5 ( $ sComponent . $ sName ) ; } if ( array_key_exists ( $ sKey , $ aTrackerArray ) ) { unset ( $ aTrackerArray [ $ sKey ] ) ; return true ...
Destroys an item in the tracker array
227,161
public function load ( $ langfile , $ lang = '' , $ return = false , $ add_suffix = true , $ alt_path = '' , $ _module = '' ) { if ( is_array ( $ langfile ) ) { foreach ( $ langfile as $ _lang ) { $ this -> load ( $ _lang ) ; } return $ this -> language ; } $ _default = CI :: $ APP -> config -> item ( 'language' ) ; $ ...
Loads a lang file
227,162
protected function setErrorReporting ( ) { error_reporting ( E_ALL ^ E_STRICT ^ E_ERROR ) ; if ( function_exists ( 'ini_set' ) ) { switch ( Environment :: get ( ) ) { case Environment :: ENV_PROD : ini_set ( 'display_errors' , false ) ; break ; default : ini_set ( 'display_errors' , true ) ; break ; } } }
Sets the appropriate error reporting values and handlers
227,163
protected function maintenanceMode ( $ force = false , $ sTitle = '' , $ sBody = '' ) { if ( $ force || file_exists ( NAILS_APP_PATH . '.MAINTENANCE' ) ) { $ oInput = Factory :: service ( 'Input' ) ; $ oUri = Factory :: service ( 'Uri' ) ; try { $ this -> load -> add_package_path ( NAILS_COMMON_PATH ) ; Factory :: serv...
Checks if Maintenance Mode is enabled shows the holding page if so .
227,164
protected function passwordProtected ( ) { $ oInput = Factory :: service ( 'Input' ) ; $ sConstantName = 'APP_USER_PASS_' . Environment :: get ( ) ; $ sConstantNameWhitelist = 'APP_USER_PASS_WHITELIST_' . Environment :: get ( ) ; if ( ! $ oInput :: isCli ( ) && defined ( $ sConstantName ) ) { if ( defined ( $ sConstant...
Checks if credentials should be requested for staging environments
227,165
protected function passwordProtectedRequest ( ) { $ oInput = Factory :: service ( 'Input' ) ; header ( 'WWW-Authenticate: Basic realm="' . APP_NAME . ' - Restricted Area"' ) ; header ( $ oInput -> server ( 'SERVER_PROTOCOL' ) . ' 401 Unauthorized' ) ; $ oErrorHandler = Factory :: service ( 'ErrorHandler' ) ; $ oErrorHa...
Requests staging credentials
227,166
protected function instantiateDateTime ( ) { $ oDateTimeService = Factory :: service ( 'DateTime' ) ; $ oDefaultDateFormat = $ oDateTimeService -> getDateFormatDefault ( ) ; if ( empty ( $ oDefaultDateFormat ) ) { throw new NailsException ( 'No default date format has been set, or it\'s been set incorrectly.' , 1 ) ; }...
Sets up date & time handling
227,167
protected function generateRoutes ( ) { if ( defined ( 'NAILS_STARTUP_GENERATE_APP_ROUTES' ) && NAILS_STARTUP_GENERATE_APP_ROUTES ) { $ oRoutesService = Factory :: service ( 'Routes' ) ; if ( ! $ oRoutesService -> update ( ) ) { throw new NailsException ( 'Failed to generate routes_app.php. ' . $ oRoutesService -> last...
Checks if routes need to be generated as part of the startup request
227,168
protected function instantiateLanguages ( ) { $ oLanguageService = Factory :: service ( 'Language' ) ; $ oDefault = $ oLanguageService -> getDefault ( ) ; if ( empty ( $ oDefault ) ) { throw new NailsException ( 'No default language has been set, or it\'s been set incorrectly.' ) ; } Functions :: define ( 'APP_DEFAULT_...
Sets up language handling
227,169
protected function definePackages ( ) { $ oConfig = Factory :: service ( 'Config' ) ; $ oConfig -> _config_paths = [ ] ; $ aPaths = [ ] ; $ aPaths [ ] = NAILS_COMMON_PATH ; $ aAvailableModules = Components :: modules ( ) ; foreach ( $ aAvailableModules as $ oModule ) { $ aPaths [ ] = $ oModule -> path ; } $ aPaths [ ] ...
Defines all the package paths
227,170
protected function isUserSuspended ( ) { if ( isLoggedIn ( ) && activeUser ( 'is_suspended' ) ) { $ oAuthModel = Factory :: model ( 'Auth' , 'nails/module-auth' ) ; $ this -> lang -> load ( 'auth/auth' ) ; $ oAuthModel -> logout ( ) ; $ oSession = Factory :: service ( 'Session' , 'nails/module-auth' ) ; $ oSession -> s...
Determines whether the active user is suspended and if so logs them out .
227,171
public static function backwardsCompatibility ( & $ oBindTo ) { $ oBindTo -> db = Factory :: service ( 'Database' ) ; $ oBindTo -> input = Factory :: service ( 'Input' ) ; $ oBindTo -> output = Factory :: service ( 'Output' ) ; $ oBindTo -> meta = Factory :: service ( 'Meta' ) ; $ oBindTo -> asset = Factory :: service ...
Provides some backwards compatability
227,172
public static function populateUserFeedback ( array & $ aData ) { $ oSession = Factory :: service ( 'Session' , 'nails/module-auth' ) ; $ oUserFeedback = Factory :: service ( 'UserFeedback' ) ; $ aData [ 'error' ] = $ oUserFeedback -> get ( 'error' ) ? : $ oSession -> getFlashData ( 'error' ) ; $ aData [ 'negative' ] =...
Populates an array from the UserFeedback and session classes
227,173
public static function populatePageData ( array & $ aData ) { $ oLocale = Factory :: service ( 'Locale' ) ; $ aData [ 'page' ] = ( object ) [ 'title' => '' , 'html_lang' => $ oLocale -> get ( ) -> getLanguage ( ) , 'seo' => ( object ) [ 'title' => '' , 'description' => '' , 'keywords' => '' , ] , ] ; }
Populates an array with a default object for page and SEO
227,174
protected function setCommonMeta ( array $ aMeta = [ ] ) { $ oMeta = Factory :: service ( 'Meta' ) ; $ oMeta -> addRaw ( [ 'charset' => 'utf-8' , ] ) -> addRaw ( [ 'name' => 'viewport' , 'content' => 'width=device-width, initial-scale=1' , ] ) ; foreach ( $ aMeta as $ aItem ) { $ oMeta -> addRaw ( $ aItem ) ; } }
Sets some common meta for every page load
227,175
public static function setNailsJs ( ) { $ oAsset = Factory :: service ( 'Asset' ) ; $ aVariables = [ 'ENVIRONMENT' => Environment :: get ( ) , 'SITE_URL' => site_url ( '' , Functions :: isPageSecure ( ) ) , 'NAILS' => ( object ) [ 'URL' => NAILS_ASSETS_URL , 'LANG' => ( object ) [ ] , 'USER' => ( object ) [ 'ID' => act...
Sets a global Nails JS object
227,176
protected function setGlobalJs ( ) { $ oAsset = Factory :: service ( 'Asset' ) ; $ sCustomJs = appSetting ( 'site_custom_js' , 'site' ) ; if ( ! empty ( $ sCustomJs ) ) { $ oAsset -> inline ( $ sCustomJs , 'JS' ) ; } $ sGoogleAnalyticsProfile = appSetting ( 'google_analytics_account' ) ; if ( ! empty ( $ sGoogleAnalyti...
Sets global JS
227,177
protected function setGlobalCss ( ) { $ oAsset = Factory :: service ( 'Asset' ) ; $ sCustomCss = appSetting ( 'site_custom_css' , 'site' ) ; if ( ! empty ( $ sCustomCss ) ) { $ oAsset -> inline ( $ sCustomCss , 'CSS' ) ; } }
Sets global CSS
227,178
protected function writeFile ( ) { $ sData = '<?php' . "\n\n" ; $ sData .= '/**' . "\n" ; $ sData .= ' * THIS FILE IS CREATED/MODIFIED AUTOMATICALLY' . "\n" ; $ sData .= ' * ===========================================' . "\n" ; $ sData .= ' *' . "\n" ; $ sData .= ' * Any changes you make in this file will be overwritte...
Write the routes file
227,179
public function canWriteRoutes ( ) { if ( ! is_null ( $ this -> bCanWriteRoutes ) ) { return $ this -> bCanWriteRoutes ; } if ( file_exists ( static :: ROUTES_DIR . static :: ROUTES_FILE ) ) { if ( is_writable ( static :: ROUTES_DIR . static :: ROUTES_FILE ) ) { $ this -> bCanWriteRoutes = true ; return true ; } else {...
Determine whether or not the routes can be written
227,180
protected function getCountCommonCompileSelect ( array & $ aData ) { if ( ! empty ( $ aData [ 'select' ] ) ) { $ oDb = Factory :: service ( 'Database' ) ; $ oDb -> select ( $ aData [ 'select' ] ) ; } }
Compiles the select statement
227,181
protected function getCountCommonCompileFiltersString ( $ sColumn , $ mValue , $ bIsQuery ) { if ( is_object ( $ mValue ) && ( $ mValue instanceof \ Closure ) ) { $ mValue = $ mValue ( ) ; } $ oDb = Factory :: service ( 'Database' ) ; if ( $ bIsQuery ) { $ aBits = [ $ mValue ] ; } elseif ( ! is_array ( $ mValue ) ) { $...
Compile the filter string
227,182
protected function getCountCommonCompileSort ( array & $ aData ) { $ oDb = Factory :: service ( 'Database' ) ; if ( ! empty ( $ aData [ 'sort' ] ) ) { if ( is_string ( $ aData [ 'sort' ] ) ) { $ oDb -> order_by ( $ aData [ 'sort' ] ) ; } elseif ( is_array ( $ aData [ 'sort' ] ) ) { $ mFirst = reset ( $ aData [ 'sort' ]...
Compiles the sort element into the query
227,183
protected function getCountCommonParseSort ( $ mSort ) { $ aOut = [ 'column' => null , 'order' => null ] ; if ( is_string ( $ mSort ) ) { $ aOut [ 'column' ] = $ mSort ; return $ aOut ; } elseif ( isset ( $ mSort [ 'column' ] ) ) { $ aOut [ 'column' ] = $ mSort [ 'column' ] ; } else { $ aOut [ 'column' ] = reset ( $ mS...
Parse the sort variable
227,184
private function buildParentLocationParameters ( ParameterBuilderInterface $ builder , array $ groups = [ ] ) : void { $ builder -> add ( 'use_current_location' , ParameterType \ Compound \ BooleanType :: class , [ 'reverse' => true , 'groups' => $ groups , ] ) ; $ builder -> get ( 'use_current_location' ) -> add ( 'pa...
Builds the parameters for filtering by parent location .
227,185
private function getParentLocation ( ParameterCollectionInterface $ parameterCollection ) : ? Location { if ( $ parameterCollection -> getParameter ( 'use_current_location' ) -> getValue ( ) === true ) { return $ this -> contentProvider -> provideLocation ( ) ; } $ parentLocationId = $ parameterCollection -> getParamet...
Returns the parent location to use for the parameter collection .
227,186
public function addHook ( $ hookwhere , $ hook ) { if ( is_array ( $ hook ) ) { if ( isset ( $ hook [ 'classref' ] ) && isset ( $ hook [ 'method' ] ) && isset ( $ hook [ 'params' ] ) ) { if ( is_object ( $ hook [ 'classref' ] ) && method_exists ( $ hook [ 'classref' ] , $ hook [ 'method' ] ) ) { $ this -> aCustomHooks ...
Adds a particular hook
227,187
public function call_hook ( $ sWhich = '' ) { if ( ! isset ( $ this -> aCustomHooks [ $ sWhich ] ) ) { return parent :: call_hook ( $ sWhich ) ; } if ( isset ( $ this -> aCustomHooks [ $ sWhich ] [ 0 ] ) && is_array ( $ this -> aCustomHooks [ $ sWhich ] [ 0 ] ) ) { foreach ( $ this -> aCustomHooks [ $ sWhich ] as $ aCu...
Call a particular hook
227,188
protected function runCustomHook ( $ aData ) { if ( ! is_array ( $ aData ) ) { return false ; } if ( $ this -> bCustomHooksInProgress == true ) { return ; } $ oClass = null ; $ sMethod = null ; $ aParams = [ ] ; if ( isset ( $ aData [ 'classref' ] ) ) { $ oClass = & $ aData [ 'classref' ] ; } if ( isset ( $ aData [ 'me...
Execute a cusotm hook
227,189
public function create ( array $ aData = [ ] , $ bReturnObject = false ) { $ mResult = parent :: create ( $ aData , $ bReturnObject ) ; if ( $ mResult ) { $ this -> saveBreadcrumbs ( $ bReturnObject ? $ mResult -> id : $ mResult ) ; $ this -> saveOrder ( ) ; if ( $ bReturnObject ) { $ mResult = $ this -> getById ( $ mR...
Generates breadcrumbs after creating an object
227,190
public function update ( $ mIds , array $ aData = [ ] ) : bool { $ mResult = parent :: update ( $ mIds , $ aData ) ; if ( $ mResult ) { $ aIds = ( array ) $ mIds ; foreach ( $ aIds as $ iId ) { $ this -> saveBreadcrumbs ( $ iId ) ; } $ this -> saveOrder ( ) ; } return $ mResult ; }
Generates breadcrumbs after updating an object
227,191
protected function saveBreadcrumbs ( $ iItemId ) { $ oItem = $ this -> getById ( $ iItemId ) ; if ( ! empty ( $ oItem ) ) { $ aBreadcrumbs = [ ] ; $ iParentId = ( int ) $ oItem -> parent_id ; while ( $ iParentId ) { $ oParentItem = $ this -> getById ( $ iParentId ) ; if ( $ oParentItem ) { $ iParentId = $ oParentItem -...
Generates breadcrumbs for the item
227,192
protected function buildTree ( array & $ aItems , int $ iParentId = null ) : array { $ aTemp = [ ] ; $ sIdColumn = $ this -> getColumn ( 'id' ) ; $ sParentColumn = $ this -> getColumn ( 'parent_id' , 'parent_id' ) ; foreach ( $ aItems as $ oItem ) { if ( $ oItem -> { $ sParentColumn } == $ iParentId ) { $ oItem -> chil...
Builds a tree of objects
227,193
protected function flattenTree ( array $ aItems , & $ aOutput = [ ] ) : array { foreach ( $ aItems as $ oItem ) { $ aOutput [ ] = $ oItem ; $ this -> flattenTree ( $ oItem -> children , $ aOutput ) ; unset ( $ oItem -> children ) ; } return $ aOutput ; }
Flattens a tree of objects
227,194
public function generateUrl ( $ oObj ) { if ( empty ( $ oObj -> breadcrumbs ) ) { return null ; } $ aBreadcrumbs = json_decode ( $ oObj -> breadcrumbs ) ; if ( is_null ( $ aBreadcrumbs ) ) { return null ; } $ aUrl = arrayExtractProperty ( $ aBreadcrumbs , 'slug' ) ; $ aUrl [ ] = $ oObj -> slug ; $ sUrl = implode ( '/' ...
Generates the URL for nestable objects ; optionally place under a URL namespace
227,195
public function getChildren ( $ iId , $ bRecursive = false , array $ aData = [ ] ) { $ aQueryData = $ aData ; if ( ! array_key_exists ( 'where' , $ aQueryData ) ) { $ aQueryData [ 'where' ] = [ ] ; } $ aQueryData [ 'where' ] [ ] = [ 'parent_id' , $ iId ] ; $ aChildren = $ this -> getAll ( $ aQueryData ) ; foreach ( $ a...
Retrieves the immediate children of an item
227,196
private function getContentType ( EzLocation $ location ) : ContentType { if ( method_exists ( $ location , 'getContent' ) && method_exists ( $ location -> getContent ( ) , 'getContentType' ) ) { return $ location -> getContent ( ) -> getContentType ( ) ; } return $ this -> repository -> getContentTypeService ( ) -> lo...
Loads the content type for provided location .
227,197
public function getAll ( $ iPage = null , $ iPerPage = null , array $ aData = [ ] , $ bIncludeDeleted = false ) : array { $ aResult = parent :: getAll ( $ iPage , $ iPerPage , $ aData , $ bIncludeDeleted ) ; $ this -> addLocaleToResources ( $ aResult ) ; return $ aResult ; }
Overloads the getAll to add a Locale object to each resource
227,198
protected function addLocaleToResource ( Resource $ oResource ) : void { $ oLocale = Factory :: service ( 'Locale' ) ; $ oResource -> locale = $ this -> getLocale ( $ oResource -> { static :: $ sColumnLanguage } , $ oResource -> { static :: $ sColumnRegion } ) ; $ oResource -> available_locales = array_map ( function (...
Adds a Locale object to a Resource and removes the language and region properties
227,199
public function getTableName ( $ bIncludeAlias = false ) : string { $ sTable = parent :: getTableName ( ) . static :: $ sLocalisedTableSuffix ; return $ bIncludeAlias ? trim ( $ sTable . ' as `' . $ this -> getTableAlias ( ) . '`' ) : $ sTable ; }
Returns the localised table name