idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
41,400 | public function findBundleClasses ( ) : array { $ bundleSets = [ ] ; $ modules = $ this -> packageRepository -> findModules ( ) ; foreach ( $ modules as $ module ) { $ extra = $ module -> getExtra ( ) ; $ this -> validateBundlesSectionInExtra ( $ extra ) ; if ( empty ( $ extra [ 'phplist/core' ] [ 'bundles' ] ) ) { continue ; } $ bundleSets [ $ module -> getName ( ) ] = $ extra [ 'phplist/core' ] [ 'bundles' ] ; } return $ bundleSets ; } | Finds the bundles class in all installed modules . |
41,401 | private function validateBundlesSectionInExtra ( array $ extra ) { if ( ! isset ( $ extra [ 'phplist/core' ] ) ) { return ; } $ this -> validatePhpListSectionInExtra ( $ extra ) ; if ( ! isset ( $ extra [ 'phplist/core' ] [ 'bundles' ] ) ) { return ; } if ( ! is_array ( $ extra [ 'phplist/core' ] [ 'bundles' ] ) ) { throw new \ InvalidArgumentException ( 'The extras.phplist/core.bundles section in the composer.json must be an array.' , 1505411665 ) ; } $ bundleExtras = $ extra [ 'phplist/core' ] [ 'bundles' ] ; foreach ( $ bundleExtras as $ key => $ bundleName ) { if ( ! is_string ( $ bundleName ) ) { throw new \ InvalidArgumentException ( 'The extras.phplist/core.bundles. ' . $ key . '" section in the composer.json must be a string.' , 1505412184 ) ; } } } | Validates the bundles section in the extra section of the composer . json of a module . |
41,402 | public function findRoutes ( ) : array { $ routes = [ ] ; $ modules = $ this -> packageRepository -> findModules ( ) ; foreach ( $ modules as $ module ) { $ extra = $ module -> getExtra ( ) ; $ this -> validateRoutesSectionInExtra ( $ extra ) ; if ( empty ( $ extra [ 'phplist/core' ] [ 'routes' ] ) ) { continue ; } $ moduleRoutes = $ extra [ 'phplist/core' ] [ 'routes' ] ; foreach ( $ moduleRoutes as $ name => $ route ) { $ prefixedRouteName = $ module -> getName ( ) . '.' . $ name ; $ routes [ $ prefixedRouteName ] = $ route ; } } return $ routes ; } | Finds the routes in all installed modules . |
41,403 | private function validateRoutesSectionInExtra ( array $ extra ) { if ( ! isset ( $ extra [ 'phplist/core' ] ) ) { return ; } $ this -> validatePhpListSectionInExtra ( $ extra ) ; if ( ! isset ( $ extra [ 'phplist/core' ] [ 'routes' ] ) ) { return ; } if ( ! is_array ( $ extra [ 'phplist/core' ] [ 'routes' ] ) ) { throw new \ InvalidArgumentException ( 'The extras.phplist/core.routes section in the composer.json must be an array.' , 1506429004 ) ; } $ bundleExtras = $ extra [ 'phplist/core' ] [ 'routes' ] ; foreach ( $ bundleExtras as $ routeName => $ routeConfiguration ) { if ( ! is_array ( $ routeConfiguration ) ) { throw new \ InvalidArgumentException ( 'The extras.phplist/core.routes. ' . $ routeName . '" section in the composer.json must be an array.' , 1506429860 ) ; } } } | Validates the routes section in the extra section of the composer . json of a module . |
41,404 | public function findGeneralConfiguration ( ) : array { $ configurationSets = [ [ ] ] ; $ modules = $ this -> packageRepository -> findModules ( ) ; foreach ( $ modules as $ module ) { $ extra = $ module -> getExtra ( ) ; $ this -> validateGeneralConfigurationSectionInExtra ( $ extra ) ; if ( ! isset ( $ extra [ 'phplist/core' ] [ 'configuration' ] ) ) { continue ; } $ configurationSets [ ] = $ extra [ 'phplist/core' ] [ 'configuration' ] ; } return array_replace_recursive ( ... $ configurationSets ) ; } | Finds and merges the configuration in all installed modules . |
41,405 | private function validateGeneralConfigurationSectionInExtra ( array $ extra ) { if ( ! isset ( $ extra [ 'phplist/core' ] ) ) { return ; } $ this -> validatePhpListSectionInExtra ( $ extra ) ; if ( ! isset ( $ extra [ 'phplist/core' ] [ 'configuration' ] ) ) { return ; } if ( ! is_array ( $ extra [ 'phplist/core' ] [ 'configuration' ] ) ) { throw new \ InvalidArgumentException ( 'The extras.phplist/core.configuration section in the composer.json must be an array.' , 1508165934 ) ; } } | Validates the configuration in the extra section of the composer . json of a module . |
41,406 | public function findOneUnexpiredByKey ( string $ key ) { $ criteria = new Criteria ( ) ; $ criteria -> where ( Criteria :: expr ( ) -> eq ( 'key' , $ key ) ) -> andWhere ( Criteria :: expr ( ) -> gt ( 'expiry' , new \ DateTime ( ) ) ) ; $ firstMatch = $ this -> matching ( $ criteria ) -> first ( ) ; return $ firstMatch ? : null ; } | Finds one unexpired token by the given key . Returns null if there is no match . |
41,407 | public function removeExpired ( ) : int { $ queryBuilder = $ this -> getEntityManager ( ) -> createQueryBuilder ( ) ; $ queryBuilder -> delete ( AdministratorToken :: class , 'token' ) -> where ( 'token.expiry <= CURRENT_TIMESTAMP()' ) ; return ( int ) $ queryBuilder -> getQuery ( ) -> execute ( ) ; } | Removes all expired tokens . |
41,408 | private function bundlesFromConfiguration ( ) : array { $ bundles = [ ] ; foreach ( $ this -> readBundleConfiguration ( ) as $ packageBundles ) { foreach ( $ packageBundles as $ bundleClassName ) { if ( class_exists ( $ bundleClassName ) ) { $ bundles [ ] = new $ bundleClassName ( ) ; } } } return $ bundles ; } | Reads the bundles from the bundle configuration file and instantiates them . |
41,409 | public function findOneByLoginCredentials ( string $ loginName , string $ plainTextPassword ) { $ passwordHash = $ this -> hashGenerator -> createPasswordHash ( $ plainTextPassword ) ; return $ this -> findOneBy ( [ 'loginName' => $ loginName , 'passwordHash' => $ passwordHash , 'superUser' => true , ] ) ; } | Finds the Administrator with the given login credentials . Returns null if there is no match i . e . if the login credentials are incorrect . |
41,410 | public function getApplicationRoot ( ) : string { $ corePackagePath = $ this -> getCorePackageRoot ( ) ; $ corePackageIsRootPackage = interface_exists ( 'PhpList\\Core\\Tests\\Support\\Interfaces\\TestMarker' ) ; if ( $ corePackageIsRootPackage ) { $ applicationRoot = $ corePackagePath ; } else { $ corePackagePath = dirname ( $ corePackagePath , 3 ) ; $ applicationRoot = $ corePackagePath ; } if ( ! file_exists ( $ applicationRoot . '/composer.json' ) ) { throw new \ RuntimeException ( 'There is no composer.json in the supposed application root "' . $ applicationRoot . '".' , 1501169001 ) ; } return $ applicationRoot ; } | Returns the absolute path to the application root . |
41,411 | private static function mirrorDirectoryFromCore ( string $ directoryWithoutSlashes ) { $ directoryWithSlashes = '/' . $ directoryWithoutSlashes . '/' ; $ fileSystem = new Filesystem ( ) ; $ fileSystem -> mirror ( static :: getCoreDirectory ( ) . $ directoryWithSlashes , static :: getApplicationRoot ( ) . $ directoryWithSlashes , null , [ 'override' => true , 'delete' => false ] ) ; } | Copies a directory from the core package . |
41,412 | public static function listModules ( Event $ event ) { $ packageRepository = new PackageRepository ( ) ; $ packageRepository -> injectComposer ( $ event -> getComposer ( ) ) ; $ modules = $ packageRepository -> findModules ( ) ; $ maximumPackageNameLength = static :: calculateMaximumPackageNameLength ( $ modules ) ; foreach ( $ modules as $ module ) { $ paddedName = str_pad ( $ module -> getName ( ) , $ maximumPackageNameLength + 1 ) ; echo $ paddedName . ' ' . $ module -> getPrettyVersion ( ) . PHP_EOL ; } } | Echos the names and version numbers of all installed phpList modules . |
41,413 | public static function warmProductionCache ( Event $ event ) { $ consoleDir = static :: getConsoleDir ( $ event , 'warm the cache' ) ; if ( $ consoleDir === null ) { return ; } static :: executeCommand ( $ event , $ consoleDir , 'cache:warm -e prod' ) ; } | Warms the production cache . |
41,414 | public function getReplace ( ) { return [ 'iblockId' => $ this -> fields [ 'IBLOCK_ID' ] , 'code' => "'" . $ this -> fields [ 'FIELD_NAME' ] . "'" , 'entity' => "'" . $ this -> fields [ 'ENTITY_ID' ] . "'" , 'fields' => var_export ( $ this -> fields , true ) , ] ; } | Get array of placeholders to replace . |
41,415 | protected function collectRows ( ) { $ rows = collect ( $ this -> collection -> all ( ) ) -> filter ( function ( $ template ) { return $ template [ 'is_alias' ] == false ; } ) -> sortBy ( 'name' ) -> map ( function ( $ template ) { $ row = [ ] ; $ names = array_merge ( [ $ template [ 'name' ] ] , $ template [ 'aliases' ] ) ; $ row [ ] = implode ( "\n/ " , $ names ) ; $ row [ ] = wordwrap ( $ template [ 'path' ] , 65 , "\n" , true ) ; $ row [ ] = wordwrap ( $ template [ 'description' ] , 25 , "\n" , true ) ; return $ row ; } ) ; return $ this -> separateRows ( $ rows ) ; } | Collect and return templates from a Migrator . |
41,416 | protected function separateRows ( $ templates ) { $ rows = [ ] ; foreach ( $ templates as $ template ) { $ rows [ ] = $ template ; $ rows [ ] = new TableSeparator ( ) ; } unset ( $ rows [ count ( $ rows ) - 1 ] ) ; return $ rows ; } | Separate rows with a separator . |
41,417 | public function createMigration ( $ name , $ templateName , array $ replace = [ ] , $ subDir = '' ) { $ targetDir = $ this -> dir ; $ subDir = trim ( str_replace ( '\\' , '/' , $ subDir ) , '/' ) ; if ( $ subDir ) { $ targetDir .= '/' . $ subDir ; } $ this -> files -> createDirIfItDoesNotExist ( $ targetDir ) ; $ fileName = $ this -> constructFileName ( $ name ) ; $ className = $ this -> getMigrationClassNameByFileName ( $ fileName ) ; $ templateName = $ this -> templates -> selectTemplate ( $ templateName ) ; $ template = $ this -> files -> getContent ( $ this -> templates -> getTemplatePath ( $ templateName ) ) ; $ template = $ this -> replacePlaceholdersInTemplate ( $ template , array_merge ( $ replace , [ 'className' => $ className ] ) ) ; $ this -> files -> putContent ( $ targetDir . '/' . $ fileName . '.php' , $ template ) ; return $ fileName ; } | Create migration file . |
41,418 | public function runMigrations ( ) { $ migrations = $ this -> getMigrationsToRun ( ) ; $ ran = [ ] ; if ( empty ( $ migrations ) ) { return $ ran ; } foreach ( $ migrations as $ migration ) { $ this -> runMigration ( $ migration ) ; $ ran [ ] = $ migration ; } return $ ran ; } | Run all migrations that were not run before . |
41,419 | public function runMigration ( $ file ) { $ migration = $ this -> getMigrationObjectByFileName ( $ file ) ; $ this -> disableBitrixIblockHelperCache ( ) ; $ this -> checkTransactionAndRun ( $ migration , function ( ) use ( $ migration , $ file ) { if ( $ migration -> up ( ) === false ) { throw new Exception ( "Migration up from {$file}.php returned false" ) ; } } ) ; $ this -> logSuccessfulMigration ( $ file ) ; } | Run a given migration . |
41,420 | public function rollbackMigration ( $ file ) { $ migration = $ this -> getMigrationObjectByFileName ( $ file ) ; $ this -> checkTransactionAndRun ( $ migration , function ( ) use ( $ migration , $ file ) { if ( $ migration -> down ( ) === false ) { throw new Exception ( "<error>Can't rollback migration:</error> {$file}.php" ) ; } } ) ; $ this -> removeSuccessfulMigrationFromLog ( $ file ) ; } | Rollback a given migration . |
41,421 | public function getMigrationsToRun ( ) { $ allMigrations = $ this -> getAllMigrations ( ) ; $ ranMigrations = $ this -> getRanMigrations ( ) ; return array_diff ( $ allMigrations , $ ranMigrations ) ; } | Get array of migrations that should be ran . |
41,422 | protected function constructFileName ( $ name ) { list ( $ usec , $ sec ) = explode ( ' ' , microtime ( ) ) ; $ usec = substr ( $ usec , 2 , 6 ) ; return date ( 'Y_m_d_His' , $ sec ) . '_' . $ usec . '_' . $ name ; } | Construct migration file name from migration name and current time . |
41,423 | protected function getMigrationClassNameByFileName ( $ file ) { $ fileExploded = explode ( '_' , $ file ) ; $ datePart = implode ( '_' , array_slice ( $ fileExploded , 0 , 5 ) ) ; $ namePart = implode ( '_' , array_slice ( $ fileExploded , 5 ) ) ; return Helpers :: studly ( $ namePart . '_' . $ datePart ) ; } | Get a migration class name by a migration file name . |
41,424 | protected function replacePlaceholdersInTemplate ( $ template , array $ replace ) { foreach ( $ replace as $ placeholder => $ value ) { $ template = str_replace ( "__{$placeholder}__" , $ value , $ template ) ; } return $ template ; } | Replace all placeholders in the stub . |
41,425 | public static function init ( $ dir , $ table = null ) { $ templates = new TemplatesCollection ( ) ; $ templates -> registerAutoTemplates ( ) ; $ config = [ 'dir' => $ dir , 'table' => is_null ( $ table ) ? 'migrations' : $ table , ] ; static :: $ migrator = new Migrator ( $ config , $ templates ) ; static :: addEventHandlers ( ) ; static :: turnOn ( ) ; } | Initialize autocreation . |
41,426 | protected static function createMigration ( HandlerInterface $ handler ) { $ migrator = static :: $ migrator ; $ notifier = new Notifier ( ) ; $ migration = $ migrator -> createMigration ( strtolower ( $ handler -> getName ( ) ) , $ handler -> getTemplate ( ) , $ handler -> getReplace ( ) ) ; $ migrator -> logSuccessfulMigration ( $ migration ) ; $ notifier -> newMigration ( $ migration ) ; } | Create migration and apply it . |
41,427 | protected static function addEventHandlers ( ) { $ eventManager = EventManager :: getInstance ( ) ; foreach ( static :: $ handlers as $ module => $ handlers ) { foreach ( $ handlers as $ event => $ handler ) { $ eventManager -> addEventHandler ( $ module , $ event , [ __CLASS__ , $ handler ] , false , 5000 ) ; } } $ eventManager -> addEventHandler ( 'main' , 'OnAfterEpilog' , function ( ) { $ notifier = new Notifier ( ) ; $ notifier -> deleteNotificationFromPreviousMigration ( ) ; return new EventResult ( ) ; } ) ; } | Add event handlers . |
41,428 | protected function showOldMigrations ( ) { $ old = collect ( $ this -> migrator -> getRanMigrations ( ) ) ; $ this -> output -> writeln ( "<fg=yellow>Old migrations:\r\n</>" ) ; $ max = 5 ; if ( $ old -> count ( ) > $ max ) { $ this -> output -> writeln ( '<fg=yellow>...</>' ) ; $ old = $ old -> take ( - $ max ) ; } foreach ( $ old as $ migration ) { $ this -> output -> writeln ( "<fg=yellow>{$migration}.php</>" ) ; } } | Show old migrations . |
41,429 | protected function showNewMigrations ( ) { $ new = collect ( $ this -> migrator -> getMigrationsToRun ( ) ) ; $ this -> output -> writeln ( "<fg=green>New migrations:\r\n</>" ) ; foreach ( $ new as $ migration ) { $ this -> output -> writeln ( "<fg=green>{$migration}.php</>" ) ; } } | Show new migrations . |
41,430 | protected function collectPropertyFieldsFromDB ( ) { $ fields = CIBlockProperty :: getByID ( $ this -> fields [ 'ID' ] ) -> fetch ( ) ; $ fields [ 'VALUES' ] = [ ] ; $ filter = [ 'IBLOCK_ID' => $ this -> fields [ 'IBLOCK_ID' ] , 'PROPERTY_ID' => $ this -> fields [ 'ID' ] , ] ; $ sort = [ 'SORT' => 'ASC' , 'VALUE' => 'ASC' , ] ; $ propertyEnums = CIBlockPropertyEnum :: GetList ( $ sort , $ filter ) ; while ( $ v = $ propertyEnums -> GetNext ( ) ) { $ fields [ 'VALUES' ] [ $ v [ 'ID' ] ] = [ 'ID' => $ v [ 'ID' ] , 'VALUE' => $ v [ 'VALUE' ] , 'SORT' => $ v [ 'SORT' ] , 'XML_ID' => $ v [ 'XML_ID' ] , 'DEF' => $ v [ 'DEF' ] , ] ; } return $ fields ; } | Collect property fields from DB and convert them to format that can be compared from user input . |
41,431 | protected function propertyHasChanged ( ) { foreach ( $ this -> dbFields as $ field => $ value ) { if ( isset ( $ this -> fields [ $ field ] ) && ( $ this -> fields [ $ field ] != $ value ) ) { return true ; } } return false ; } | Determine if property has been changed . |
41,432 | public function registerBasicTemplates ( ) { $ templates = [ [ 'name' => 'add_iblock' , 'path' => $ this -> dir . '/add_iblock.template' , 'description' => 'Add iblock' , ] , [ 'name' => 'add_iblock_type' , 'path' => $ this -> dir . '/add_iblock_type.template' , 'description' => 'Add iblock type' , ] , [ 'name' => 'add_iblock_element_property' , 'path' => $ this -> dir . '/add_iblock_element_property.template' , 'description' => 'Add iblock element property' , 'aliases' => [ 'add_iblock_prop' , 'add_iblock_element_prop' , 'add_element_prop' , 'add_element_property' , ] , ] , [ 'name' => 'add_uf' , 'path' => $ this -> dir . '/add_uf.template' , 'description' => 'Add user field (for sections, users e.t.c)' , ] , [ 'name' => 'add_table' , 'path' => $ this -> dir . '/add_table.template' , 'description' => 'Create table' , 'aliases' => [ 'create_table' , ] , ] , [ 'name' => 'delete_table' , 'path' => $ this -> dir . '/delete_table.template' , 'description' => 'Drop table' , 'aliases' => [ 'drop_table' , ] , ] , [ 'name' => 'query' , 'path' => $ this -> dir . '/query.template' , 'description' => 'Simple database query' , ] , ] ; foreach ( $ templates as $ template ) { $ this -> registerTemplate ( $ template ) ; } } | Register basic templates . |
41,433 | public function registerAutoTemplates ( ) { $ templates = [ 'add_iblock' , 'update_iblock' , 'delete_iblock' , 'add_iblock_element_property' , 'update_iblock_element_property' , 'delete_iblock_element_property' , 'add_uf' , 'update_uf' , 'delete_uf' , 'add_hlblock' , 'update_hlblock' , 'delete_hlblock' , 'add_group' , 'update_group' , 'delete_group' , ] ; foreach ( $ templates as $ template ) { $ this -> registerTemplate ( [ 'name' => 'auto_' . $ template , 'path' => $ this -> dir . '/auto/' . $ template . '.template' , ] ) ; } } | Register templates for automigrations . |
41,434 | public function registerTemplate ( $ template ) { $ template = $ this -> normalizeTemplateDuringRegistration ( $ template ) ; $ this -> templates [ $ template [ 'name' ] ] = $ template ; $ this -> registerTemplateAliases ( $ template , $ template [ 'aliases' ] ) ; } | Dynamically register migration template . |
41,435 | public function selectTemplate ( $ template ) { if ( is_null ( $ template ) ) { return 'default' ; } if ( ! array_key_exists ( $ template , $ this -> templates ) ) { throw new RuntimeException ( "Template \"{$template}\" is not registered" ) ; } return $ template ; } | Find out template name from user input . |
41,436 | protected function normalizeTemplateDuringRegistration ( $ template ) { if ( empty ( $ template [ 'name' ] ) ) { throw new InvalidArgumentException ( 'Impossible to register a template without "name"' ) ; } if ( empty ( $ template [ 'path' ] ) ) { throw new InvalidArgumentException ( 'Impossible to register a template without "path"' ) ; } $ template [ 'description' ] = isset ( $ template [ 'description' ] ) ? $ template [ 'description' ] : '' ; $ template [ 'aliases' ] = isset ( $ template [ 'aliases' ] ) ? $ template [ 'aliases' ] : [ ] ; $ template [ 'is_alias' ] = false ; return $ template ; } | Check template fields and normalize them . |
41,437 | protected function registerTemplateAliases ( $ template , array $ aliases = [ ] ) { foreach ( $ aliases as $ alias ) { $ template [ 'is_alias' ] = true ; $ template [ 'name' ] = $ alias ; $ template [ 'aliases' ] = [ ] ; $ this -> templates [ $ template [ 'name' ] ] = $ template ; } } | Register template aliases . |
41,438 | protected function fieldsHaveBeenChanged ( ) { $ old = HighloadBlockTable :: getById ( $ this -> id ) -> fetch ( ) ; $ new = $ this -> fields + [ 'ID' => ( string ) $ this -> id ] ; return $ new != $ old ; } | Determine if fields have been changed . |
41,439 | protected function rollbackMigration ( $ migration ) { if ( $ this -> migrator -> doesMigrationFileExist ( $ migration ) ) { $ this -> migrator -> rollbackMigration ( $ migration ) ; } else { $ this -> markRolledBackWithConfirmation ( $ migration ) ; } $ this -> message ( "<info>Rolled back:</info> {$migration}.php" ) ; } | Call rollback . |
41,440 | protected function markRolledBackWithConfirmation ( $ migration ) { $ helper = $ this -> getHelper ( 'question' ) ; $ question = new ConfirmationQuestion ( "<error>Migration $migration was not found.\r\nDo you want to mark it as rolled back? (y/n)</error>\r\n" , false ) ; if ( ! $ helper -> ask ( $ this -> input , $ this -> output , $ question ) ) { $ this -> abort ( ) ; } $ this -> migrator -> removeSuccessfulMigrationFromLog ( $ migration ) ; } | Ask a user to confirm rolling back non - existing migration and remove it from log . |
41,441 | protected function deleteIfNeeded ( $ migration ) { if ( ! $ this -> input -> getOption ( 'delete' ) ) { return ; } if ( $ this -> migrator -> deleteMigrationFile ( $ migration ) ) { $ this -> message ( "<info>Deleted:</info> {$migration}.php" ) ; } } | Delete migration file if options is set |
41,442 | public function getRanMigrations ( ) { $ migrations = [ ] ; $ dbRes = $ this -> db -> query ( "SELECT MIGRATION FROM {$this->table} ORDER BY ID ASC" ) ; while ( $ result = $ dbRes -> fetch ( ) ) { $ migrations [ ] = $ result [ 'MIGRATION' ] ; } return $ migrations ; } | Get an array of migrations the have been ran previously . Must be ordered by order asc . |
41,443 | public function logSuccessfulMigration ( $ name ) { $ this -> db -> insert ( $ this -> table , [ 'MIGRATION' => "'" . $ this -> db -> forSql ( $ name ) . "'" , ] ) ; } | Save migration name to the database to prevent it from running again . |
41,444 | public function findOneByEmailIgnoreHidden ( $ email ) { $ query = $ this -> createQuery ( ) ; $ query -> getQuerySettings ( ) -> setIgnoreEnableFields ( TRUE ) ; $ query -> matching ( $ query -> equals ( 'email' , $ email ) ) ; return $ query -> execute ( ) -> getFirst ( ) ; } | Returns an Object by email address and ignores hidden field . |
41,445 | public function findAllByRegisteraddresshash ( $ hash ) { $ query = $ this -> createQuery ( ) ; $ query -> matching ( $ query -> equals ( 'registeraddresshash' , $ hash ) ) ; return $ query -> execute ( ) ; } | Returns all Objects by hash . |
41,446 | public function processDatamap_postProcessFieldArray ( $ status , $ table , $ id , array & $ fieldArray , DataHandler $ pObj ) { if ( $ table === 'tt_address' && $ status === 'new' ) { if ( empty ( $ fieldArray [ 'registeraddresshash' ] ) ) { $ rnd = microtime ( true ) . random_int ( 10000 , 90000 ) ; $ regHash = sha1 ( $ fieldArray [ 'email' ] . $ rnd ) ; $ fieldArray [ 'registeraddresshash' ] = $ regHash ; } } } | Hook method for postProcessFieldArray |
41,447 | protected function getPlainRenderer ( $ templateName = 'default' , $ format = 'txt' ) { $ view = $ this -> objectManager -> get ( StandaloneView :: class ) ; $ view -> getRequest ( ) -> setControllerExtensionName ( 'registeraddress' ) ; $ view -> setFormat ( $ format ) ; $ frameworkConfiguration = $ this -> configurationManager -> getConfiguration ( ConfigurationManagerInterface :: CONFIGURATION_TYPE_FRAMEWORK ) ; $ partialPaths = $ this -> getViewProperty ( $ frameworkConfiguration , 'partialRootPaths' ) ; $ view -> setPartialRootPaths ( $ partialPaths ) ; $ templatePaths = $ this -> getViewProperty ( $ frameworkConfiguration , 'templateRootPaths' ) ; $ view -> setTemplateRootPaths ( $ templatePaths ) ; $ layoutPaths = $ this -> getViewProperty ( $ frameworkConfiguration , 'layoutRootPaths' ) ; $ view -> setLayoutRootPaths ( $ layoutPaths ) ; $ view -> setTemplate ( $ templateName ) ; $ view -> assign ( 'settings' , $ this -> settings ) ; return $ view ; } | This creates another stand - alone instance of the Fluid view to render a template |
41,448 | protected function sendResponseMail ( $ recipientmails = '' , $ templateName , array $ data = NULL , $ type = self :: MAILFORMAT_TXT , $ subjectSuffix = '' ) { $ oldSpamProtectSetting = $ GLOBALS [ 'TSFE' ] -> spamProtectEmailAddresses ; $ GLOBALS [ 'TSFE' ] -> spamProtectEmailAddresses = 0 ; $ recipients = explode ( ',' , $ recipientmails ) ; $ from = [ $ this -> settings [ 'sendermail' ] => $ this -> settings [ 'sendername' ] ] ; $ subject = $ this -> settings [ 'responseSubject' ] ; if ( $ subjectSuffix != '' ) { $ subject .= ' - ' . $ subjectSuffix ; } $ mailHtml = '' ; $ mailText = '' ; switch ( $ type ) { case self :: MAILFORMAT_TXT : $ mailTextView = $ this -> getPlainRenderer ( $ templateName , 'txt' ) ; break ; case self :: MAILFORMAT_HTML : $ mailHtmlView = $ this -> getPlainRenderer ( $ templateName , 'html' ) ; break ; case self :: MAILFORMAT_TXTHTML : $ mailHtmlView = $ this -> getPlainRenderer ( $ templateName , 'html' ) ; default : $ mailTextView = $ this -> getPlainRenderer ( $ templateName , 'txt' ) ; break ; } if ( isset ( $ mailTextView ) ) { $ mailTextView -> assignMultiple ( $ data ) ; $ mailText = $ mailTextView -> render ( ) ; } if ( isset ( $ mailHtmlView ) ) { $ mailHtmlView -> assignMultiple ( $ data ) ; $ mailHtml = $ mailHtmlView -> render ( ) ; } foreach ( $ recipients as $ recipient ) { $ recipientMail = [ trim ( $ recipient ) ] ; $ this -> sendEmail ( $ recipientMail , $ from , $ subject , $ mailHtml , $ mailText ) ; } $ GLOBALS [ 'TSFE' ] -> spamProtectEmailAddresses = $ oldSpamProtectSetting ; } | sends an e - mail to users |
41,449 | private function checkIfAddressExists ( $ address ) { $ oldAddress = $ this -> addressRepository -> findOneByEmailIgnoreHidden ( $ address ) ; return isset ( $ oldAddress ) && $ oldAddress ? $ oldAddress : null ; } | checks if address already exists |
41,450 | public function informationAction ( $ email , $ uid ) { $ address = $ this -> addressRepository -> findOneByEmailIgnoreHidden ( $ email ) ; if ( $ address && $ address -> getUid ( ) == $ uid ) { $ data = [ 'address' => $ address , 'hash' => $ address -> getRegisteraddresshash ( ) ] ; if ( $ address -> getHidden ( ) ) { $ mailTemplate = 'Address/MailNewsletterRegistration' ; } else { $ mailTemplate = 'Address/MailNewsletterInformation' ; } $ this -> sendResponseMail ( $ address -> getEmail ( ) , $ mailTemplate , $ data , $ this -> settings [ 'mailformat' ] , LocalizationUtility :: translate ( 'mail.info.subjectsuffix' , 'registeraddress' ) ) ; $ this -> view -> assign ( 'address' , $ address ) ; } } | action inormation mail anforderung |
41,451 | public function unsubscribeFormAction ( $ email = NULL ) { $ address = $ this -> addressRepository -> findOneByEmail ( $ email ) ; if ( $ email != NULL ) { $ this -> view -> assign ( 'email' , $ email ) ; } if ( $ address ) { $ data = [ 'address' => $ address , 'hash' => $ address -> getRegisteraddresshash ( ) ] ; $ mailTemplate = 'Address/MailNewsletterUnsubscribe' ; $ this -> sendResponseMail ( $ address -> getEmail ( ) , $ mailTemplate , $ data , $ this -> settings [ 'mailformat' ] , LocalizationUtility :: translate ( 'mail.unsubscribe.subjectsuffix' , 'registeraddress' ) ) ; $ this -> view -> assign ( 'address' , $ address ) ; } } | action send unsubscribe link to e - mail address |
41,452 | public function access ( ) { $ typo3Version = VersionNumberUtility :: getNumericTypo3Version ( ) ; if ( VersionNumberUtility :: convertVersionNumberToInteger ( $ typo3Version ) >= 8000000 ) { $ count = $ this -> queryBuilder -> count ( 'uid' ) -> from ( 'tt_address' ) -> where ( $ this -> queryBuilder -> expr ( ) -> eq ( 'registeraddresshash' , $ this -> queryBuilder -> createNamedParameter ( '' ) ) ) -> execute ( ) -> fetchColumn ( 0 ) ; } else { $ count = $ this -> databaseConnection -> exec_SELECTcountRows ( 'uid' , 'tt_address' , 'registeraddresshash=""' ) ; } return ( $ count > 0 ) ; } | Called by the extension manager to determine if the update menu entry should by showed . |
41,453 | public function extractVersion ( $ string ) { preg_match_all ( $ this -> config -> get ( 'git.version.matcher' ) , $ string , $ matches ) ; if ( empty ( $ matches [ 0 ] ) ) { throw new GitTagNotFound ( 'No git tags found in this repository' ) ; } return $ matches ; } | Break and extract version from string . |
41,454 | public function makeGitVersionRetrieverCommand ( $ mode = null ) { $ mode = is_null ( $ mode ) ? $ this -> config -> get ( 'version_source' ) : $ mode ; return $ this -> searchAndReplaceRepository ( $ this -> config -> get ( 'git.version.' . $ mode ) ) ; } | Make a git version command . |
41,455 | public function getCommit ( $ mode = null ) { return $ this -> getFromGit ( $ this -> makeGitHashRetrieverCommand ( $ mode ) , Constants :: VERSION_CACHE_KEY , $ this -> config -> get ( 'build.length' , 6 ) ) ; } | Get the current git commit number to be used as build number . |
41,456 | public function getGitHashRetrieverCommand ( $ mode = null ) { $ mode = is_null ( $ mode ) ? $ this -> config -> get ( 'build.mode' ) : $ mode ; return $ this -> config -> get ( 'git.' . $ mode ) ; } | Get the git hash retriever command . |
41,457 | protected function getFromGit ( $ command , $ keySuffix , $ length = 256 ) { if ( $ value = $ this -> cache -> get ( $ key = $ this -> cache -> key ( $ keySuffix ) ) ) { return $ value ; } $ value = substr ( $ this -> shell ( $ command ) , 0 , $ length ) ; $ this -> cache -> put ( $ key , $ value ) ; return $ value ; } | Get a cached value or execute a shell command to retrieve it . |
41,458 | public function getVersionFromGit ( $ mode = null ) { return $ this -> getFromGit ( $ this -> makeGitVersionRetrieverCommand ( $ mode ) , Constants :: BUILD_CACHE_KEY ) ; } | Get the current app version from Git . |
41,459 | public function version ( $ type ) { $ version = $ this -> extractVersion ( $ this -> getVersionFromGit ( ) ) ; return [ 'major' => $ this -> getMatchedVersionItem ( $ version , 1 ) , 'minor' => $ this -> getMatchedVersionItem ( $ version , 2 ) , 'patch' => $ this -> getMatchedVersionItem ( $ version , 3 ) , 'build' => $ this -> getMatchedVersionItem ( $ version , 4 ) , ] [ $ type ] ; } | Get version from the git repository . |
41,460 | protected function shell ( $ command ) { $ process = new Process ( $ command , $ this -> getBasePath ( ) ) ; $ process -> run ( ) ; if ( ! $ process -> isSuccessful ( ) ) { return '' ; } return $ this -> cleanOutput ( $ process -> getOutput ( ) ) ; } | Execute an shell command . |
41,461 | private function absorbVersion ( ) { if ( ( $ type = $ this -> config -> get ( 'current.git_absorb' ) ) === false ) { return ; } $ version = $ this -> git -> extractVersion ( $ this -> git -> getVersionFromGit ( $ type ) ) ; $ config = $ this -> config -> getRoot ( ) ; $ config [ 'current' ] [ 'major' ] = ( int ) $ version [ 1 ] [ 0 ] ; $ config [ 'current' ] [ 'minor' ] = ( int ) $ version [ 2 ] [ 0 ] ; $ config [ 'current' ] [ 'patch' ] = ( int ) $ version [ 3 ] [ 0 ] ; $ this -> config -> update ( $ config ) ; } | Absorb the version number from git . |
41,462 | private function absorbBuild ( ) { if ( ( $ type = $ this -> config -> get ( 'build.git_absorb' ) ) === false ) { return ; } $ config = $ this -> config -> getRoot ( ) ; $ config [ 'build' ] [ 'number' ] = $ this -> git -> getCommit ( $ type ) ; $ this -> config -> update ( $ config ) ; } | Absorb the build from git . |
41,463 | public function loadConfig ( $ config = null ) { $ config = ! is_null ( $ config ) || ! file_exists ( $ this -> configFile ) ? $ this -> setConfigFile ( $ this -> getConfigFile ( $ config ) ) : $ this -> configFile ; return $ this -> loadToLaravelConfig ( $ config ) ; } | Load package YAML configuration . |
41,464 | public function getConfigFile ( $ file = null ) { $ file = $ file ? : $ this -> configFile ; return file_exists ( $ file ) ? $ file : $ this -> getConfigFileStub ( ) ; } | Get the config file path . |
41,465 | public function update ( $ config ) { config ( [ 'version' => $ config ] ) ; $ this -> yaml -> saveAsYaml ( $ config , $ this -> configFile ) ; } | Update the config file . |
41,466 | protected function registerService ( ) { $ this -> app -> singleton ( 'pragmarx.version' , function ( ) { $ version = new Version ( $ this -> config ) ; $ version -> setConfigFileStub ( $ this -> getConfigFileStub ( ) ) ; return $ version ; } ) ; } | Register service service . |
41,467 | public function put ( $ key , $ value , $ minutes = 10 ) { IlluminateCache :: put ( $ key , $ value , $ this -> config -> get ( 'cache.time' , $ minutes ) ) ; } | Add something to the cache . |
41,468 | public function flush ( ) { IlluminateCache :: forget ( $ this -> key ( Constants :: BUILD_CACHE_KEY ) ) ; IlluminateCache :: forget ( $ this -> key ( Constants :: VERSION_CACHE_KEY ) ) ; } | Get the current object instance . |
41,469 | public function incrementBuild ( $ by = null ) { return $ this -> increment ( function ( $ config ) use ( $ by ) { $ increment_by = $ by ? : $ config [ 'build' ] [ 'increment_by' ] ; $ config [ 'build' ] [ 'number' ] = $ config [ 'build' ] [ 'number' ] + $ increment_by ; return $ config ; } , 'build.number' ) ; } | Increment the build number . |
41,470 | protected function getVersion ( $ type ) { return $ this -> git -> isVersionComingFromGit ( ) ? $ this -> git -> version ( $ type ) : $ this -> config -> get ( "current.{$type}" ) ; } | Get a version . |
41,471 | protected function instantiateClass ( $ instance , $ property , $ class = null , $ arguments = [ ] ) { return $ this -> { $ property } = is_null ( $ instance ) ? ( $ instance = new $ class ( ... $ arguments ) ) : $ instance ; } | Instantiate a class . |
41,472 | protected function replaceVariables ( $ string ) { do { $ original = $ string ; $ string = $ this -> searchAndReplaceVariables ( $ string ) ; } while ( $ original !== $ string ) ; return $ string ; } | Replace text variables with their values . |
41,473 | public function getBuild ( ) { if ( $ this -> git -> isVersionComingFromGit ( ) && ( $ value = $ this -> git -> version ( 'build' ) ) ) { return $ value ; } if ( $ this -> config -> get ( 'build.mode' ) === Constants :: BUILD_MODE_NUMBER ) { return $ this -> config -> get ( 'build.number' ) ; } return $ this -> git -> getCommit ( ) ; } | Get the current build . |
41,474 | protected function fixLocale ( $ locale ) { if ( in_array ( $ locale , $ this -> supportedLocales ) ) { return $ locale ; } if ( ( $ short = Fixer :: getLanguageFromLocale ( $ locale ) ) !== $ locale ) { if ( in_array ( $ short , $ this -> supportedLocales ) ) { return $ short ; } } return $ locale ; } | Transform fr_FR to fr to fit the list of supported locales . |
41,475 | public function fixSiblingNode ( $ key , $ new_content ) { $ storedSibling = $ this -> getSiblingNode ( $ key ) ; if ( $ storedSibling ) { $ storedSibling -> getParent ( ) -> replaceChild ( $ storedSibling -> getDocument ( ) -> createTextNode ( $ new_content ) , $ storedSibling -> getNode ( ) ) ; unset ( $ this -> siblingNode [ $ key ] [ $ this -> currentDepth ] ) ; } } | Replace and destroy the content of a stored Node . |
41,476 | private function compileRules ( $ rules ) { if ( ! is_array ( $ rules ) || empty ( $ rules ) ) { throw new BadRuleSetException ( 'Rules must be an array of Fixer' ) ; } $ this -> _rules = [ ] ; foreach ( $ rules as $ rule ) { if ( is_object ( $ rule ) ) { $ fixer = $ rule ; $ className = get_class ( $ rule ) ; } else { $ className = class_exists ( $ rule ) ? $ rule : ( class_exists ( 'JoliTypo\\Fixer\\' . $ rule ) ? 'JoliTypo\\Fixer\\' . $ rule : false ) ; if ( ! $ className ) { throw new BadRuleSetException ( sprintf ( 'Fixer %s not found' , $ rule ) ) ; } $ fixer = new $ className ( $ this -> getLocale ( ) ) ; } if ( ! $ fixer instanceof FixerInterface ) { throw new BadRuleSetException ( sprintf ( '%s must implement FixerInterface' , $ className ) ) ; } $ this -> _rules [ $ className ] = $ fixer ; } if ( empty ( $ this -> _rules ) ) { throw new BadRuleSetException ( "No rules configured, can't fix the content!" ) ; } } | Build the _rules array of Fixer . |
41,477 | private function processDOM ( \ DOMNode $ node , \ DOMDocument $ dom ) { if ( $ node -> hasChildNodes ( ) ) { $ nodes = [ ] ; foreach ( $ node -> childNodes as $ childNode ) { if ( $ childNode instanceof \ DOMElement && $ childNode -> tagName ) { if ( in_array ( $ childNode -> tagName , $ this -> protectedTags ) ) { continue ; } } $ nodes [ ] = $ childNode ; } $ depth = $ this -> stateBag -> getCurrentDepth ( ) ; foreach ( $ nodes as $ childNode ) { if ( $ childNode instanceof \ DOMText && ! $ childNode -> isWhitespaceInElementContent ( ) ) { $ this -> stateBag -> setCurrentDepth ( $ depth ) ; $ this -> doFix ( $ childNode , $ node , $ dom ) ; } else { $ this -> stateBag -> setCurrentDepth ( $ this -> stateBag -> getCurrentDepth ( ) + 1 ) ; $ this -> processDOM ( $ childNode , $ dom ) ; } } } } | Loop over all the DOMNode recursively . |
41,478 | private function doFix ( \ DOMText $ childNode , \ DOMNode $ node , \ DOMDocument $ dom ) { $ content = $ childNode -> wholeText ; $ current_node = new StateNode ( $ childNode , $ node , $ dom ) ; $ this -> stateBag -> setCurrentNode ( $ current_node ) ; foreach ( $ this -> _rules as $ fixer ) { $ content = $ fixer -> fix ( $ content , $ this -> stateBag ) ; } if ( $ childNode -> wholeText !== $ content ) { $ new_node = $ dom -> createTextNode ( $ content ) ; $ node -> replaceChild ( $ new_node , $ childNode ) ; $ current_node -> replaceNode ( $ new_node ) ; } } | Run the Fixers on a DOMText content . |
41,479 | private function fixContentEncoding ( $ content ) { if ( ! empty ( $ content ) ) { if ( false === strpos ( $ content , '<?xml encoding' ) ) { $ hack = false === strpos ( $ content , '<body' ) ? '<?xml encoding="UTF-8"><body>' : '<?xml encoding="UTF-8">' ; $ content = $ hack . $ content ; } $ encoding = mb_detect_encoding ( $ content ) ; $ headPos = mb_strpos ( $ content , '<head>' ) ; if ( false !== $ headPos ) { $ headPos += 6 ; $ content = mb_substr ( $ content , 0 , $ headPos ) . '<meta http-equiv="Content-Type" content="text/html; charset=' . $ encoding . '">' . mb_substr ( $ content , $ headPos ) ; } $ content = mb_convert_encoding ( $ content , 'HTML-ENTITIES' , $ encoding ) ; } return $ content ; } | Convert the content encoding properly and add Content - Type meta if HTML document . |
41,480 | public function setLocale ( $ locale ) { if ( ! is_string ( $ locale ) || empty ( $ locale ) ) { throw new \ InvalidArgumentException ( 'Locale must be an IETF language tag.' ) ; } foreach ( $ this -> _rules as $ rule ) { if ( $ rule instanceof LocaleAwareFixerInterface ) { $ rule -> setLocale ( $ locale ) ; } } $ this -> locale = $ locale ; } | Change the locale of the Fixer . |
41,481 | public function setLocale ( $ locale ) { switch ( strtolower ( $ locale ) ) { case 'pt-br' : $ this -> opening = Fixer :: LDQUO ; $ this -> openingSuffix = '' ; $ this -> closing = Fixer :: RDQUO ; $ this -> closingPrefix = '' ; return ; } $ short = Fixer :: getLanguageFromLocale ( $ locale ) ; switch ( $ short ) { case 'fr' : $ this -> opening = Fixer :: LAQUO ; $ this -> openingSuffix = Fixer :: NO_BREAK_SPACE ; $ this -> closing = Fixer :: RAQUO ; $ this -> closingPrefix = Fixer :: NO_BREAK_SPACE ; break ; case 'hy' : case 'az' : case 'hz' : case 'eu' : case 'be' : case 'ca' : case 'el' : case 'it' : case 'no' : case 'fa' : case 'lv' : case 'pt' : case 'ru' : case 'es' : case 'uk' : $ this -> opening = Fixer :: LAQUO ; $ this -> openingSuffix = '' ; $ this -> closing = Fixer :: RAQUO ; $ this -> closingPrefix = '' ; break ; case 'de' : case 'ka' : case 'cs' : case 'et' : case 'is' : case 'lt' : case 'mk' : case 'ro' : case 'sk' : case 'sl' : case 'wen' : $ this -> opening = Fixer :: BDQUO ; $ this -> openingSuffix = '' ; $ this -> closing = Fixer :: LDQUO ; $ this -> closingPrefix = '' ; break ; case 'en' : case 'us' : case 'gb' : case 'af' : case 'ar' : case 'eo' : case 'id' : case 'ga' : case 'ko' : case 'br' : case 'th' : case 'tr' : case 'vi' : $ this -> opening = Fixer :: LDQUO ; $ this -> openingSuffix = '' ; $ this -> closing = Fixer :: RDQUO ; $ this -> closingPrefix = '' ; break ; case 'fi' : case 'sv' : case 'bs' : $ this -> opening = Fixer :: RDQUO ; $ this -> openingSuffix = '' ; $ this -> closing = Fixer :: RDQUO ; $ this -> closingPrefix = '' ; break ; } } | Default configuration for supported lang . |
41,482 | protected function prepareData ( $ value ) { if ( is_string ( $ value ) ) { return stripslashes ( trim ( str_replace ( '\n' , "\n" , $ value ) ) ) ; } elseif ( is_array ( $ value ) ) { return array_map ( 'self::prepareData' , $ value ) ; } return $ value ; } | Prepares the data for output |
41,483 | public function printData ( $ html = self :: HTML_TEMPLATE ) { $ data = array ( 'SUMMARY' => $ this -> summary , 'DTSTART' => $ this -> dtstart , 'DTEND' => $ this -> dtend , 'DTSTART_TZ' => $ this -> dtstart_tz , 'DTEND_TZ' => $ this -> dtend_tz , 'DURATION' => $ this -> duration , 'DTSTAMP' => $ this -> dtstamp , 'UID' => $ this -> uid , 'CREATED' => $ this -> created , 'LAST-MODIFIED' => $ this -> lastmodified , 'DESCRIPTION' => $ this -> description , 'LOCATION' => $ this -> location , 'SEQUENCE' => $ this -> sequence , 'STATUS' => $ this -> status , 'TRANSP' => $ this -> transp , 'ORGANISER' => $ this -> organizer , 'ATTENDEE(S)' => $ this -> attendee , ) ; $ data = array_filter ( $ data ) ; $ output = '' ; foreach ( $ data as $ key => $ value ) { $ output .= sprintf ( $ html , $ key , $ value ) ; } return $ output ; } | Returns Event data excluding anything blank within an HTML template |
41,484 | protected static function snakeCase ( $ input , $ glue = '_' , $ separator = '-' ) { $ input = preg_split ( '/(?<=[a-z])(?=[A-Z])/x' , $ input ) ; $ input = join ( $ input , $ glue ) ; $ input = str_replace ( $ separator , $ glue , $ input ) ; return strtolower ( $ input ) ; } | Converts the given input to snake_case |
41,485 | public function initString ( $ string ) { if ( empty ( $ this -> cal ) ) { $ lines = explode ( PHP_EOL , $ string ) ; $ this -> initLines ( $ lines ) ; } else { trigger_error ( 'ICal::initString: Calendar already initialised in constructor' , E_USER_NOTICE ) ; } return $ this ; } | Initialises lines from a string |
41,486 | public function initFile ( $ file ) { if ( empty ( $ this -> cal ) ) { $ lines = $ this -> fileOrUrl ( $ file ) ; $ this -> initLines ( $ lines ) ; } else { trigger_error ( 'ICal::initFile: Calendar already initialised in constructor' , E_USER_NOTICE ) ; } return $ this ; } | Initialises lines from a file |
41,487 | public function initUrl ( $ url , $ username = null , $ password = null , $ userAgent = null ) { if ( ! is_null ( $ username ) && ! is_null ( $ password ) ) { $ this -> httpBasicAuth [ 'username' ] = $ username ; $ this -> httpBasicAuth [ 'password' ] = $ password ; } if ( ! is_null ( $ userAgent ) ) { $ this -> httpUserAgent = $ userAgent ; } $ this -> initFile ( $ url ) ; return $ this ; } | Initialises lines from a URL |
41,488 | protected function reduceEventsToMinMaxRange ( ) { $ events = ( isset ( $ this -> cal [ 'VEVENT' ] ) ) ? $ this -> cal [ 'VEVENT' ] : array ( ) ; if ( ! empty ( $ events ) ) { foreach ( $ events as $ key => $ anEvent ) { if ( $ this -> doesEventStartOutsideWindow ( $ anEvent ) ) { $ this -> eventCount -- ; unset ( $ events [ $ key ] ) ; continue ; } } $ this -> cal [ 'VEVENT' ] = $ events ; } } | Reduces the number of events to the defined minimum and maximum range |
41,489 | protected function isOutOfRange ( $ calendarDate , $ minTimestamp , $ maxTimestamp ) { $ timestamp = strtotime ( explode ( 'T' , $ calendarDate ) [ 0 ] ) ; return $ timestamp < $ minTimestamp || $ timestamp > $ maxTimestamp ; } | Determines whether a valid iCalendar date is within a given range |
41,490 | public function iCalDateToUnixTimestamp ( $ icalDate , $ forceTimeZone = false , $ forceUtc = false ) { $ dateTime = $ this -> iCalDateToDateTime ( $ icalDate , $ forceTimeZone , $ forceUtc ) ; return $ dateTime -> getTimestamp ( ) ; } | Returns a Unix timestamp from an iCal date time format |
41,491 | public function iCalDateWithTimeZone ( array $ event , $ key , $ format = self :: DATE_TIME_FORMAT ) { if ( ! isset ( $ event [ $ key . '_array' ] ) || ! isset ( $ event [ $ key ] ) ) { return false ; } $ dateArray = $ event [ $ key . '_array' ] ; if ( $ key === 'DURATION' ) { $ duration = end ( $ dateArray ) ; $ dateTime = $ this -> parseDuration ( $ event [ 'DTSTART' ] , $ duration , null ) ; } else { $ dateTime = new \ DateTime ( $ dateArray [ 1 ] , new \ DateTimeZone ( self :: TIME_ZONE_UTC ) ) ; $ dateTime -> setTimezone ( new \ DateTimeZone ( $ this -> calendarTimeZone ( ) ) ) ; } if ( isset ( $ dateArray [ 0 ] [ 'TZID' ] ) ) { if ( $ this -> isValidIanaTimeZoneId ( $ dateArray [ 0 ] [ 'TZID' ] ) ) { $ dateTime -> setTimezone ( new \ DateTimeZone ( $ dateArray [ 0 ] [ 'TZID' ] ) ) ; } elseif ( $ this -> isValidCldrTimeZoneId ( $ dateArray [ 0 ] [ 'TZID' ] ) ) { $ dateTime -> setTimezone ( new \ DateTimeZone ( $ this -> isValidCldrTimeZoneId ( $ dateArray [ 0 ] [ 'TZID' ] , true ) ) ) ; } else { $ dateTime -> setTimezone ( new \ DateTimeZone ( $ this -> defaultTimeZone ) ) ; } } if ( is_null ( $ format ) ) { $ output = $ dateTime ; } else { if ( $ format === self :: UNIX_FORMAT ) { $ output = $ dateTime -> getTimestamp ( ) ; } else { $ output = $ dateTime -> format ( $ format ) ; } } return $ output ; } | Returns a date adapted to the calendar time zone depending on the event TZID |
41,492 | protected function processDateConversions ( ) { $ events = ( isset ( $ this -> cal [ 'VEVENT' ] ) ) ? $ this -> cal [ 'VEVENT' ] : array ( ) ; if ( ! empty ( $ events ) ) { foreach ( $ events as $ key => $ anEvent ) { if ( ! $ this -> isValidDate ( $ anEvent [ 'DTSTART' ] ) ) { unset ( $ events [ $ key ] ) ; $ this -> eventCount -- ; continue ; } if ( $ this -> useTimeZoneWithRRules && isset ( $ anEvent [ 'RRULE_array' ] [ 2 ] ) && $ anEvent [ 'RRULE_array' ] [ 2 ] === self :: RECURRENCE_EVENT ) { $ events [ $ key ] [ 'DTSTART_tz' ] = $ anEvent [ 'DTSTART' ] ; $ events [ $ key ] [ 'DTEND_tz' ] = isset ( $ anEvent [ 'DTEND' ] ) ? $ anEvent [ 'DTEND' ] : $ anEvent [ 'DTSTART' ] ; } else { $ events [ $ key ] [ 'DTSTART_tz' ] = $ this -> iCalDateWithTimeZone ( $ anEvent , 'DTSTART' ) ; if ( $ this -> iCalDateWithTimeZone ( $ anEvent , 'DTEND' ) ) { $ events [ $ key ] [ 'DTEND_tz' ] = $ this -> iCalDateWithTimeZone ( $ anEvent , 'DTEND' ) ; } elseif ( $ this -> iCalDateWithTimeZone ( $ anEvent , 'DURATION' ) ) { $ events [ $ key ] [ 'DTEND_tz' ] = $ this -> iCalDateWithTimeZone ( $ anEvent , 'DURATION' ) ; } elseif ( $ this -> iCalDateWithTimeZone ( $ anEvent , 'DTSTART' ) ) { $ events [ $ key ] [ 'DTEND_tz' ] = $ this -> iCalDateWithTimeZone ( $ anEvent , 'DTSTART' ) ; } } } $ this -> cal [ 'VEVENT' ] = $ events ; } } | Processes date conversions using the time zone |
41,493 | public function events ( ) { $ array = $ this -> cal ; $ array = isset ( $ array [ 'VEVENT' ] ) ? $ array [ 'VEVENT' ] : array ( ) ; $ events = array ( ) ; if ( ! empty ( $ array ) ) { foreach ( $ array as $ event ) { $ events [ ] = new Event ( $ event ) ; } } return $ events ; } | Returns an array of Events . Every event is a class with the event details being properties within it . |
41,494 | public function calendarTimeZone ( $ ignoreUtc = false ) { if ( isset ( $ this -> cal [ 'VCALENDAR' ] [ 'X-WR-TIMEZONE' ] ) ) { $ timeZone = $ this -> cal [ 'VCALENDAR' ] [ 'X-WR-TIMEZONE' ] ; } elseif ( isset ( $ this -> cal [ 'VTIMEZONE' ] [ 'TZID' ] ) ) { $ timeZone = $ this -> cal [ 'VTIMEZONE' ] [ 'TZID' ] ; } else { $ timeZone = $ this -> defaultTimeZone ; } if ( $ this -> isValidIanaTimeZoneId ( $ timeZone ) === false ) { if ( ( $ timeZone = $ this -> isValidCldrTimeZoneId ( $ timeZone , true ) ) === false ) { $ timeZone = $ this -> defaultTimeZone ; } } if ( $ ignoreUtc && strtoupper ( $ timeZone ) === self :: TIME_ZONE_UTC ) { return null ; } return $ timeZone ; } | Returns the calendar time zone |
41,495 | public function eventsFromRange ( $ rangeStart = null , $ rangeEnd = null ) { $ events = $ this -> sortEventsWithOrder ( $ this -> events ( ) , SORT_ASC ) ; if ( empty ( $ events ) ) { return array ( ) ; } $ extendedEvents = array ( ) ; if ( ! is_null ( $ rangeStart ) ) { try { $ rangeStart = new \ DateTime ( $ rangeStart , new \ DateTimeZone ( $ this -> defaultTimeZone ) ) ; } catch ( \ Exception $ e ) { error_log ( "ICal::eventsFromRange: Invalid date passed ({$rangeStart})" ) ; $ rangeStart = false ; } } else { $ rangeStart = new \ DateTime ( 'now' , new \ DateTimeZone ( $ this -> defaultTimeZone ) ) ; } if ( ! is_null ( $ rangeEnd ) ) { try { $ rangeEnd = new \ DateTime ( $ rangeEnd , new \ DateTimeZone ( $ this -> defaultTimeZone ) ) ; } catch ( \ Exception $ e ) { error_log ( "ICal::eventsFromRange: Invalid date passed ({$rangeEnd})" ) ; $ rangeEnd = false ; } } else { $ rangeEnd = new \ DateTime ( 'now' , new \ DateTimeZone ( $ this -> defaultTimeZone ) ) ; $ rangeEnd -> modify ( '+20 years' ) ; } if ( $ rangeEnd -> format ( 'His' ) == 0 && $ rangeStart -> getTimestamp ( ) == $ rangeEnd -> getTimestamp ( ) ) { $ rangeEnd -> modify ( '+1 day' ) ; } $ rangeStart = $ rangeStart -> getTimestamp ( ) ; $ rangeEnd = $ rangeEnd -> getTimestamp ( ) ; foreach ( $ events as $ anEvent ) { $ eventStart = $ anEvent -> dtstart_array [ 2 ] ; $ eventEnd = ( isset ( $ anEvent -> dtend_array [ 2 ] ) ) ? $ anEvent -> dtend_array [ 2 ] : null ; if ( ( $ eventStart >= $ rangeStart && $ eventStart < $ rangeEnd ) || ( $ eventEnd !== null && ( ( $ eventEnd > $ rangeStart && $ eventEnd <= $ rangeEnd ) || ( $ eventStart < $ rangeStart && $ eventEnd > $ rangeEnd ) ) ) ) { $ extendedEvents [ ] = $ anEvent ; } } if ( empty ( $ extendedEvents ) ) { return array ( ) ; } return $ extendedEvents ; } | Returns a sorted array of the events in a given range or an empty array if no events exist in the range . |
41,496 | public function eventsFromInterval ( $ interval ) { $ rangeStart = new \ DateTime ( 'now' , new \ DateTimeZone ( $ this -> defaultTimeZone ) ) ; $ rangeEnd = new \ DateTime ( 'now' , new \ DateTimeZone ( $ this -> defaultTimeZone ) ) ; $ dateInterval = \ DateInterval :: createFromDateString ( $ interval ) ; $ rangeEnd -> add ( $ dateInterval ) ; return $ this -> eventsFromRange ( $ rangeStart -> format ( 'Y-m-d' ) , $ rangeEnd -> format ( 'Y-m-d' ) ) ; } | Returns a sorted array of the events following a given string or false if no events exist in the range . |
41,497 | public function sortEventsWithOrder ( array $ events , $ sortOrder = SORT_ASC ) { $ extendedEvents = array ( ) ; $ timestamp = array ( ) ; foreach ( $ events as $ key => $ anEvent ) { $ extendedEvents [ ] = $ anEvent ; $ timestamp [ $ key ] = $ anEvent -> dtstart_array [ 2 ] ; } array_multisort ( $ timestamp , $ sortOrder , $ extendedEvents ) ; return $ extendedEvents ; } | Sorts events based on a given sort order |
41,498 | protected function isValidIanaTimeZoneId ( $ timeZone ) { if ( in_array ( $ timeZone , $ this -> validTimeZones ) ) { return true ; } $ valid = array ( ) ; $ tza = timezone_abbreviations_list ( ) ; foreach ( $ tza as $ zone ) { foreach ( $ zone as $ item ) { $ valid [ $ item [ 'timezone_id' ] ] = true ; } } unset ( $ valid [ '' ] ) ; if ( isset ( $ valid [ $ timeZone ] ) || in_array ( $ timeZone , timezone_identifiers_list ( \ DateTimeZone :: ALL_WITH_BC ) ) ) { $ this -> validTimeZones [ ] = $ timeZone ; return true ; } return false ; } | Checks if a time zone is a valid IANA time zone |
41,499 | protected function parseDuration ( $ date , $ duration , $ format = self :: UNIX_FORMAT ) { $ dateTime = date_create ( $ date ) ; $ dateTime -> modify ( $ duration -> y . ' year' ) ; $ dateTime -> modify ( $ duration -> m . ' month' ) ; $ dateTime -> modify ( $ duration -> d . ' day' ) ; $ dateTime -> modify ( $ duration -> h . ' hour' ) ; $ dateTime -> modify ( $ duration -> i . ' minute' ) ; $ dateTime -> modify ( $ duration -> s . ' second' ) ; if ( is_null ( $ format ) ) { $ output = $ dateTime ; } else { if ( $ format === self :: UNIX_FORMAT ) { $ output = $ dateTime -> getTimestamp ( ) ; } else { $ output = $ dateTime -> format ( $ format ) ; } } return $ output ; } | Parses a duration and applies it to a date |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.