idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
25,200 | private function _doExecuteCached ( Query $ query ) { if ( null !== $ resultCache = $ this -> documentManager -> getResultCache ( ) ) { $ item = $ resultCache -> getItem ( $ this -> cacheProfile -> getCacheKey ( ) ) ; if ( $ item -> isHit ( ) ) { yield from $ item -> get ( ) ; return ; } } $ resultSets = iterator_to_array ( $ this -> _doExecute ( $ query ) ) ; if ( isset ( $ item ) ) { $ item -> set ( $ resultSets ) ; $ item -> expiresAfter ( $ this -> cacheProfile -> getTtl ( ) ) ; $ resultCache -> save ( $ item ) ; } yield from $ resultSets ; } | Executes a cached query . |
25,201 | public function init ( ) { $ libPhoneNumber = PhoneNumberUtil :: getInstance ( ) ; $ optionsList = [ ] ; foreach ( $ libPhoneNumber -> getSupportedRegions ( ) as $ code ) { $ fullTextCountry = \ Locale :: getDisplayRegion ( 'en_' . $ code , 'en' ) ; $ optionsList [ $ code ] = $ fullTextCountry ; } asort ( $ optionsList ) ; $ this -> setValueOptions ( $ optionsList ) ; } | set up option list |
25,202 | public function subscribe ( $ eventName , $ callable , $ priority = 0 ) { if ( ! is_callable ( $ callable ) ) { throw new SubscriberNotCallable ( ) ; } $ this -> eventList [ $ eventName ] [ $ priority ] [ ] = $ callable ; unset ( $ this -> sorted [ $ eventName ] ) ; return $ this ; } | Subscribe to an Event with either a closure or callable structure |
25,203 | public function sortSubscribers ( $ eventName ) { $ this -> sorted [ $ eventName ] = array ( ) ; if ( isset ( $ this -> eventList [ $ eventName ] ) ) { krsort ( $ this -> eventList [ $ eventName ] ) ; $ this -> sorted [ $ eventName ] = call_user_func_array ( 'array_merge' , $ this -> eventList [ $ eventName ] ) ; } return $ this -> sorted [ $ eventName ] ; } | Sort Subscribers in reverse priority order - higher priority first |
25,204 | public function queue ( $ eventName , $ payload = array ( ) ) { $ me = $ this ; $ this -> subscribe ( $ eventName . self :: QUEUE_NAME , function ( ) use ( $ me , $ eventName , $ payload ) { return $ me -> dispatch ( $ eventName , $ payload ) ; } ) ; } | Defer dispatching of an event or events until flush is called . |
25,205 | public function flush ( $ eventName ) { $ result = $ this -> dispatch ( $ eventName . self :: QUEUE_NAME ) ; if ( is_array ( $ result ) ) { $ result = call_user_func_array ( 'array_merge' , $ result ) ; } return $ result ; } | Flush Event Queue |
25,206 | public function parseAddress ( $ address ) { $ exp = '!^wss?://([\w-.]+?)(?::(\d+))?(/.*)?$!' ; $ matches = array ( ) ; if ( ! preg_match ( $ exp , $ address , $ matches ) ) { throw new Net_Notifier_ClientException ( sprintf ( 'Invalid WebSocket address: %s. Should be in the form ' . 'ws://host[:port][/resource]' , $ address ) ) ; } if ( isset ( $ matches [ 1 ] ) ) { $ this -> setHost ( $ matches [ 1 ] ) ; } if ( isset ( $ matches [ 2 ] ) ) { $ this -> setPort ( $ matches [ 2 ] ) ; } if ( isset ( $ matches [ 3 ] ) ) { $ this -> setResource ( $ matches [ 3 ] ) ; } return $ this ; } | Parses a WebSocket address and sets the constituent parts for this client |
25,207 | protected function connect ( ) { $ this -> socket = new Net_Notifier_Socket_Client ( sprintf ( 'tcp://%s:%s' , $ this -> host , $ this -> port ) , $ this -> timeout / 1000 ) ; $ this -> connection = new Net_Notifier_WebSocket_Connection ( $ this -> socket ) ; $ this -> connection -> startHandshake ( $ this -> host , $ this -> port , $ this -> resource , array ( Net_Notifier_WebSocket :: PROTOCOL ) ) ; $ state = $ this -> connection -> getState ( ) ; while ( $ state < Net_Notifier_WebSocket_Connection :: STATE_OPEN ) { $ read = array ( $ this -> socket -> getRawSocket ( ) ) ; $ result = stream_select ( $ read , $ write = null , $ except = null , null ) ; if ( $ result === 1 ) { $ this -> connection -> read ( self :: READ_BUFFER_LENGTH ) ; } $ state = $ this -> connection -> getState ( ) ; } } | Connects this client to the cha - ching server |
25,208 | protected function disconnect ( ) { $ this -> connection -> startClose ( Net_Notifier_WebSocket_Connection :: CLOSE_GOING_AWAY , 'Client sent message.' ) ; $ state = $ this -> connection -> getState ( ) ; $ sec = intval ( $ this -> timeout / 1000 ) ; $ usec = ( $ this -> timeout % 1000 ) * 1000 ; while ( $ state < Net_Notifier_WebSocket_Connection :: STATE_CLOSED ) { $ read = array ( $ this -> socket -> getRawSocket ( ) ) ; $ result = stream_select ( $ read , $ write = null , $ except = null , $ sec , $ usec ) ; if ( $ result === 1 ) { $ this -> connection -> read ( self :: READ_BUFFER_LENGTH ) ; } else { $ this -> connection -> close ( ) ; } $ state = $ this -> connection -> getState ( ) ; } $ this -> connection = null ; } | Disconnects this client from the server |
25,209 | public function getClass ( $ type ) { if ( ! isset ( $ this -> cls [ $ type ] ) ) { throw new \ InvalidArgumentException ( 'Invalid type' ) ; } return $ this -> cls [ $ type ] ; } | Returns the class used to wrap scalar types . |
25,210 | public function setClass ( $ type , $ cls ) { if ( ! isset ( $ this -> cls [ $ type ] ) ) { throw new \ InvalidArgumentException ( 'Invalid type' ) ; } if ( ! is_string ( $ cls ) ) { throw new \ InvalidArgumentException ( 'Expected a string for the class' ) ; } if ( ! class_exists ( $ cls ) ) { throw new \ InvalidArgumentException ( 'Class not found' ) ; } if ( ! ( $ cls instanceof \ Erebot \ Styling \ VariableInterface ) ) { throw new \ InvalidArgumentException ( 'Must be a subclass of \\Erebot\\Styling\\VariableInterface' ) ; } $ this -> cls [ $ type ] = $ cls ; } | Sets the class to use to wrap a certain scalar type . |
25,211 | protected function wrapScalar ( $ var , $ name ) { self :: checkVariableName ( $ name ) ; if ( is_object ( $ var ) ) { if ( $ var instanceof \ Erebot \ Styling \ VariableInterface ) { return $ var ; } if ( ! is_callable ( array ( $ var , '__toString' ) , false ) ) { throw new \ InvalidArgumentException ( $ name . ' must be a scalar or an instance of ' . '\\Erebot\\Styling\\VariableInterface' ) ; } } if ( is_array ( $ var ) ) { return $ var ; } if ( is_string ( $ var ) || is_callable ( array ( $ var , '__toString' ) , false ) ) { $ cls = $ this -> cls [ 'string' ] ; } elseif ( is_int ( $ var ) ) { $ cls = $ this -> cls [ 'int' ] ; } elseif ( is_float ( $ var ) ) { $ cls = $ this -> cls [ 'float' ] ; } else { throw new \ InvalidArgumentException ( 'Unsupported scalar type (' . gettype ( $ var ) . ') for "' . $ name . '"' ) ; } return new $ cls ( $ var ) ; } | Wraps a scalar into the appropriate styling object . |
25,212 | protected static function parseTemplate ( $ source ) { $ source = '<msg xmlns="http://www.erebot.net/xmlns/erebot/styling">' . $ source . '</msg>' ; $ schema = dirname ( __DIR__ ) . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'styling.rng' ; $ dom = new \ Erebot \ DOM ( ) ; $ dom -> substituteEntities = true ; $ dom -> resolveExternals = false ; $ dom -> recover = true ; $ ue = libxml_use_internal_errors ( true ) ; $ dom -> loadXML ( $ source ) ; $ valid = $ dom -> relaxNGValidate ( $ schema ) ; $ errors = $ dom -> getErrors ( ) ; libxml_use_internal_errors ( $ ue ) ; if ( ! $ valid || count ( $ errors ) ) { if ( class_exists ( '\\Plop\\Plop' ) ) { $ logger = \ Plop \ Plop :: getInstance ( ) ; $ logger -> error ( print_r ( $ errors , true ) ) ; } throw new \ InvalidArgumentException ( 'Error while validating the message' ) ; } return $ dom ; } | Parses a template into a DOM . |
25,213 | private function parseChildren ( $ node , & $ attributes , $ vars ) { $ result = '' ; for ( $ child = $ node -> firstChild ; $ child != null ; $ child = $ child -> nextSibling ) { $ result .= $ this -> parseNode ( $ child , $ attributes , $ vars ) ; } return $ result ; } | This method is used to apply the parsing method to children of an XML node . |
25,214 | public function BasicParameters ( & $ Request ) { $ Request = array_merge ( $ Request , array ( 'ServerHostname' => Url ( '/' , TRUE ) , 'ServerType' => Gdn :: Request ( ) -> GetValue ( 'SERVER_SOFTWARE' ) , 'PHPVersion' => phpversion ( ) , 'VanillaVersion' => APPLICATION_VERSION ) ) ; } | Automatically configures a ProxyRequest array with basic parameters such as IP VanillaVersion RequestTime Hostname PHPVersion ServerType . |
25,215 | public function Check ( ) { if ( ! self :: CheckIsAllowed ( ) ) { return ; } Gdn :: Controller ( ) -> AddDefinition ( 'AnalyticsTask' , 'tick' ) ; if ( self :: CheckIsEnabled ( ) ) { Gdn :: Controller ( ) -> AddDefinition ( 'TickExtra' , $ this -> GetEncodedTickExtra ( ) ) ; } } | This method is called each page request and checks the environment . If a stats send is warranted tells the browser to ping us back . |
25,216 | public function Sign ( & $ Request , $ Modify = FALSE ) { $ VanillaID = GetValue ( 'VanillaID' , $ Request , FALSE ) ; if ( empty ( $ VanillaID ) ) return FALSE ; if ( $ VanillaID != Gdn :: InstallationID ( ) ) return FALSE ; $ SignatureArray = $ Request ; $ RequestTime = Gdn_Statistics :: Time ( ) ; $ RequestSecret = Gdn :: InstallationSecret ( ) ; unset ( $ SignatureArray [ 'SecurityHash' ] ) ; $ SignatureArray [ 'Secret' ] = $ RequestSecret ; $ SignatureArray [ 'RequestTime' ] = $ RequestTime ; $ SignData = array_intersect_key ( $ SignatureArray , array_fill_keys ( array ( 'VanillaID' , 'Secret' , 'RequestTime' , 'TimeSlot' ) , NULL ) ) ; $ SignData = array_change_key_case ( $ SignData , CASE_LOWER ) ; ksort ( $ SignData ) ; $ RealHash = sha1 ( http_build_query ( $ SignData ) ) ; if ( $ Modify ) { $ Request [ 'RequestTime' ] = $ RequestTime ; $ Request [ 'SecurityHash' ] = $ RealHash ; ksort ( $ Request ) ; } return $ RealHash ; } | Sign a request or response |
25,217 | public function Tick ( ) { $ this -> EventArguments [ 'Path' ] = Gdn :: Request ( ) -> Post ( 'Path' ) ; $ this -> FireEvent ( 'Tick' ) ; $ ViewType = 'normal' ; if ( preg_match ( '`discussion/embed`' , Gdn :: Request ( ) -> Post ( 'ResolvedPath' , '' ) ) ) $ ViewType = 'embed' ; $ this -> AddView ( $ ViewType ) ; if ( ! self :: CheckIsEnabled ( ) ) return ; if ( Gdn :: Session ( ) -> CheckPermission ( 'Garden.Settings.Manage' ) ) { if ( Gdn :: Get ( 'Garden.Analytics.Notify' , FALSE ) !== FALSE ) { $ CallMessage = Sprite ( 'Bandaid' , 'InformSprite' ) ; $ CallMessage .= sprintf ( T ( "There's a problem with Vanilla Analytics that needs your attention.<br/> Handle it <a href=\"%s\">here »</a>" ) , Url ( 'dashboard/statistics' ) ) ; Gdn :: Controller ( ) -> InformMessage ( $ CallMessage , array ( 'CssClass' => 'HasSprite' ) ) ; } } $ InstallationID = Gdn :: InstallationID ( ) ; if ( is_null ( $ InstallationID ) ) { $ ConfFile = PATH_CONF . '/config.php' ; if ( ! is_writable ( $ ConfFile ) ) { if ( Gdn :: Session ( ) -> CheckPermission ( 'Garden.Settings.Manage' ) ) { $ Warning = Sprite ( 'Sliders' , 'InformSprite' ) ; $ Warning .= T ( 'Your config.php file is not writable.<br/> Find out <a href="http://vanillaforums.org/docs/vanillastatistics">how to fix this »</a>' ) ; Gdn :: Controller ( ) -> InformMessage ( $ Warning , array ( 'CssClass' => 'HasSprite' ) ) ; } return ; } $ AttemptedRegistration = Gdn :: Get ( 'Garden.Analytics.Registering' , FALSE ) ; if ( $ AttemptedRegistration !== FALSE && ( time ( ) - $ AttemptedRegistration ) < 60 ) return ; return $ this -> Register ( ) ; } $ LastSentDate = self :: LastSentDate ( ) ; if ( empty ( $ LastSentDate ) || $ LastSentDate < date ( 'Ymd' , strtotime ( '-1 day' ) ) ) return $ this -> Stats ( ) ; } | This is the asynchronous callback |
25,218 | public function AddView ( $ ViewType = 'normal' ) { $ TimeSlot = date ( 'Ymd' ) ; $ Px = Gdn :: Database ( ) -> DatabasePrefix ; $ Views = 1 ; $ EmbedViews = 0 ; try { if ( C ( 'Garden.Analytics.Views.Denormalize' , FALSE ) && Gdn :: Cache ( ) -> ActiveEnabled ( ) ) { $ CacheKey = "QueryCache.Analytics.CountViews" ; $ Incremented = Gdn :: Cache ( ) -> Increment ( $ CacheKey ) ; if ( $ Incremented === Gdn_Cache :: CACHEOP_FAILURE ) Gdn :: Cache ( ) -> Store ( $ CacheKey , 1 ) ; $ Views = Gdn :: Cache ( ) -> Get ( $ CacheKey ) ; if ( $ ViewType == 'embed' ) { $ EmbedCacheKey = "QueryCache.Analytics.CountEmbedViews" ; $ EmbedIncremented = Gdn :: Cache ( ) -> Increment ( $ EmbedCacheKey ) ; if ( $ EmbedIncremented === Gdn_Cache :: CACHEOP_FAILURE ) Gdn :: Cache ( ) -> Store ( $ EmbedCacheKey , 1 ) ; $ EmbedViews = Gdn :: Cache ( ) -> Get ( $ EmbedCacheKey ) ; } $ DenormalizeWriteback = C ( 'Garden.Analytics.Views.DenormalizeWriteback' , 10 ) ; if ( ( $ Views % $ DenormalizeWriteback ) == 0 ) { Gdn :: Controller ( ) -> SetData ( 'WritebackViews' , $ Views ) ; Gdn :: Controller ( ) -> SetData ( 'WritebackEmbed' , $ EmbedViews ) ; Gdn :: Database ( ) -> Query ( "insert into {$Px}AnalyticsLocal (TimeSlot, Views, EmbedViews) values (:TimeSlot, {$Views}, {$EmbedViews}) on duplicate key update Views = COALESCE(Views, 0)+{$Views}, EmbedViews = COALESCE(EmbedViews, 0)+{$EmbedViews}" , array ( ':TimeSlot' => $ TimeSlot ) ) ; if ( $ Views ) Gdn :: Cache ( ) -> Decrement ( $ CacheKey , $ Views ) ; if ( $ EmbedViews ) Gdn :: Cache ( ) -> Decrement ( $ EmbedCacheKey , $ EmbedViews ) ; } } else { $ ExtraViews = 1 ; $ ExtraEmbedViews = ( $ ViewType == 'embed' ) ? 1 : 0 ; Gdn :: Database ( ) -> Query ( "insert into {$Px}AnalyticsLocal (TimeSlot, Views, EmbedViews) values (:TimeSlot, {$ExtraViews}, {$ExtraEmbedViews}) on duplicate key update Views = COALESCE(Views, 0)+{$ExtraViews}, EmbedViews = COALESCE(EmbedViews, 0)+{$ExtraEmbedViews}" , array ( ':TimeSlot' => $ TimeSlot ) ) ; } } catch ( Exception $ Ex ) { if ( Gdn :: Session ( ) -> CheckPermission ( 'Garden.Settings.Manage' ) ) throw $ Ex ; } } | Increments overall pageview view count |
25,219 | final protected function denormalizeDetailedShow ( array $ data ) { $ detailedShow = new DetailedShow ( ) ; $ referenceMap = [ 'showid' => 'setShowId' , 'name' => 'setName' , 'showname' => 'setName' , 'link' => 'setLink' , 'image' => 'setImage' , 'showlink' => 'setLink' , 'ended' => 'setEnded' , 'country' => 'setCountry' , 'origin_country' => 'setOriginCountry' , 'seasons' => 'setSeasonCount' , 'totalseasons' => 'setSeasonCount' , 'status' => 'setStatus' , 'runtime' => 'setRuntime' , 'classification' => 'setClassification' , 'airtime' => 'setAirtime' , 'airday' => 'setAirday' , 'timezone' => 'setTimeZone' ] ; $ complexMap = [ 'akas' => 'handleAkas' , 'genres' => 'handleGenres' , 'network' => 'handleNetwork' , 'Episodelist' => 'handleEpisodeList' , ] ; $ ignore = [ 'startdate' => null , 'started' => null , ] ; foreach ( $ data as $ attribute => $ value ) { if ( array_key_exists ( $ attribute , $ referenceMap ) ) { $ detailedShow -> $ referenceMap [ $ attribute ] ( $ value ) ; } elseif ( array_key_exists ( $ attribute , $ complexMap ) ) { $ this -> $ complexMap [ $ attribute ] ( $ detailedShow , $ value ) ; } elseif ( ! array_key_exists ( $ attribute , $ ignore ) ) { throw new UnimplementedAttributeException ( sprintf ( 'Attribute %s is not implemented' , $ attribute ) ) ; } } return $ detailedShow ; } | Denormalize Detailed Show |
25,220 | protected function handleAkas ( DetailedShow $ show , array $ akas ) { if ( ! array_key_exists ( 'aka' , $ akas ) ) { return ; } if ( is_string ( $ akas [ 'aka' ] ) ) { $ akas [ 'aka' ] = [ [ '#' => $ akas [ 'aka' ] ] ] ; } foreach ( $ akas [ 'aka' ] as $ attributes ) { $ aka = new Aka ( ) ; if ( is_string ( $ attributes ) ) { $ aka -> setTitle ( $ attributes ) ; $ show -> addAka ( $ aka ) ; continue ; } if ( array_key_exists ( '@attr' , $ attributes ) ) { $ aka -> setAttr ( $ attributes [ '@attr' ] ) ; } if ( array_key_exists ( '@country' , $ attributes ) ) { $ aka -> setCountry ( $ attributes [ '@country' ] ) ; } if ( array_key_exists ( '#' , $ attributes ) ) { $ aka -> setTitle ( $ attributes [ '#' ] ) ; } $ show -> addAka ( $ aka ) ; } } | Handle A . K . A s |
25,221 | public function resolve ( MediaType $ mediaType , $ requestedSize = null ) { $ icons = $ mediaType -> getIcons ( ) ; if ( ! count ( $ icons ) ) { return null ; } ksort ( $ icons ) ; if ( isset ( $ icons [ $ requestedSize ] ) ) { $ icon = $ icons [ $ requestedSize ] ; } else { $ icon = null ; foreach ( $ icons as $ size => $ dummyIcon ) { if ( $ size > $ requestedSize ) { $ icon = $ dummyIcon ; break ; } } if ( ! $ icon ) { $ icon = end ( $ icons ) ; } } return $ this -> locator -> locate ( $ icon , null , true ) ; } | Resolve icon . |
25,222 | public function ormClearCacheMetadata ( $ opt = [ 'flush' => false ] ) { $ validOpts = [ 'flush' ] ; $ command = new Command \ ClearCache \ MetadataCommand ; $ this -> runDoctrineCommand ( $ command , $ opt , $ validOpts ) ; } | Clear all metadata cache of the various cache drivers |
25,223 | public function ormClearCacheResult ( $ opt = [ 'flush' => false ] ) { $ validOpts = [ 'flush' ] ; $ command = new Command \ ClearCache \ ResultCommand ; $ this -> runDoctrineCommand ( $ command , $ opt , $ validOpts ) ; } | Clear all result cache of the various cache drivers |
25,224 | public function ormClearCacheQuery ( $ opt = [ 'flush' => false ] ) { $ validOpts = [ 'flush' ] ; $ command = new Command \ ClearCache \ QueryCommand ; $ this -> runDoctrineCommand ( $ command , $ opt , $ validOpts ) ; } | Clear all query cache of the various cache drivers |
25,225 | public function ormSchemaCreate ( $ opt = [ 'dump-sql' => false ] ) { $ validOpts = [ 'dump-sql' ] ; $ command = new Command \ SchemaTool \ CreateCommand ; $ this -> runDoctrineCommand ( $ command , $ opt , $ validOpts ) ; } | Processes the schema and either create it directly on EntityManager Storage Connection or generate the SQL output |
25,226 | public function ormSchemaDrop ( $ opt = [ 'dump-sql' => false , 'force' => false , 'full-database' => false ] ) { $ validOpts = [ 'dump-sql' , 'force' , 'full-database' ] ; $ command = new Command \ SchemaTool \ DropCommand ; $ this -> runDoctrineCommand ( $ command , $ opt , $ validOpts ) ; } | Drop the complete database schema of EntityManager Storage Connection or generate the corresponding SQL output |
25,227 | public function ormEnsureProductionSettings ( $ opt = [ 'complete' => false ] ) { $ validOpts = [ 'complete' ] ; $ command = new Command \ EnsureProductionSettingsCommand ; $ this -> runDoctrineCommand ( $ command , $ opt , $ validOpts ) ; } | Verify that Doctrine is properly configured for a production environment |
25,228 | public function ormConvertD1Schema ( $ fromPath , $ toType , $ destPath , $ from , $ to , $ opt = [ 'extend' => null , 'num-spaces' => 4 ] ) { $ validOpts = [ 'extend' , 'num-spaces' ] ; $ command = new Command \ ConvertDoctrine1SchemaCommand ; $ arg = [ 'from-path' => $ fromPath , 'to-type' => $ toType , 'dest-path' => $ destPath , 'from' => $ from , 'to' => $ to , ] ; $ this -> runDoctrineCommand ( $ command , $ opt , $ validOpts , $ arg ) ; } | Converts Doctrine 1 . X schema into a Doctrine 2 . X schema |
25,229 | public function ormGenerateRepositories ( $ destPath , $ opt = [ 'filter' => null ] ) { $ validOpts = [ 'filter' ] ; $ command = new Command \ GenerateRepositoriesCommand ; $ arg = [ 'dest-path' => $ destPath , ] ; $ this -> runDoctrineCommand ( $ command , $ opt , $ validOpts , $ arg ) ; } | Generate repository classes from your mapping information |
25,230 | public function ormGenerateEntities ( $ destPath , $ opt = [ 'filter' => null , 'generate-annotations' => false , 'generate-methods' => true , 'regenerate-entities' => false , 'update-entities' => true , 'extend' => false , 'num-spaces' => 4 , ] ) { $ validOpts = [ 'filter' , 'generate-annotations' , 'generate-methods' , 'regenerate-entities' , 'update-entities' , 'extend' , 'num-spaces' , ] ; $ command = new Command \ GenerateEntitiesCommand ; $ arg = [ 'dest-path' => $ destPath , ] ; $ this -> runDoctrineCommand ( $ command , $ opt , $ validOpts , $ arg ) ; } | Generate entity classes and method stubs from your mapping information |
25,231 | public function ormGenerateProxies ( $ destPath = null , $ opt = [ 'filter' => null ] ) { $ validOpts = [ 'filter' ] ; $ command = new Command \ GenerateProxiesCommand ; $ arg = [ 'dest-path' => $ destPath , ] ; $ this -> runDoctrineCommand ( $ command , $ opt , $ validOpts , $ arg ) ; } | Generates proxy classes for entity classes |
25,232 | public function ormConvertMapping ( $ toType , $ destPath , $ opt = [ 'filter' => null , 'force' => null , 'from-database' => null , 'extend' => null , 'num-spaces' => 4 , 'namespace' => null , ] ) { $ validOpts = [ 'filter' , 'force' , 'from-database' , 'extend' , 'num-spaces' , 'namespace' , ] ; $ command = new Command \ ConvertMappingCommand ; $ arg = [ 'to-type' => $ toType , 'dest-path' => $ destPath , ] ; $ this -> runDoctrineCommand ( $ command , $ opt , $ validOpts , $ arg ) ; } | Convert mapping information between supported formats |
25,233 | public function ormRunDql ( $ dql , $ opt = [ 'hydrate' => 'object' , 'first-result' => null , 'max-result' => null , 'depth' => 7 , ] ) { $ validOpts = [ 'hydrate' , 'first-result' , 'max-result' , 'depth' , ] ; $ command = new Command \ RunDqlCommand ; $ arg = [ 'dql' => $ dql , ] ; $ this -> runDoctrineCommand ( $ command , $ opt , $ arg ) ; } | Executes arbitrary DQL directly from the command line |
25,234 | protected function runDoctrineCommand ( SymfonyCommand $ command , array $ opt = [ ] , array $ validOpts = [ ] , array $ arg = [ ] ) { $ helperSet = $ this -> getEntityManagerHelperSet ( ) ; $ command -> setHelperSet ( $ helperSet ) ; $ command = $ this -> taskSymfonyCommand ( $ command ) ; foreach ( $ opt as $ key => $ value ) { if ( ! in_array ( $ key , $ validOpts ) ) { continue ; } $ command -> opt ( $ key , $ value ) ; } foreach ( $ arg as $ key => $ value ) { $ command -> arg ( $ key , $ value ) ; } $ command -> run ( ) ; } | Adds options to a symfony command |
25,235 | public function setRedirectUrl ( $ options ) { $ this -> redirectUrl = array ( 404 => ! isset ( $ options [ 404 ] ) ? '' : $ options [ 404 ] , 405 => ! isset ( $ options [ 405 ] ) ? '' : $ options [ 405 ] ) ; } | Ganti error page |
25,236 | public function setUser ( array $ user ) { $ this -> user = array_intersect_key ( $ user , array_flip ( $ this -> getUserAttributes ( ) ) ) ; return $ this ; } | Set user data . |
25,237 | public function getMaxPriority ( $ materialId , $ structureId ) { $ tableMaterialIds = dbQuery ( 'material' ) -> cond ( 'parent_id' , $ materialId ) -> cond ( 'type' , 3 ) -> cond ( 'Active' , 1 ) -> cond ( 'Draft' , 0 ) -> join ( 'structurematerial' ) -> cond ( 'structurematerial.StructureID' , $ structureId ) -> fields ( 'MaterialID' ) ; $ material = null ; if ( dbQuery ( 'material' ) -> cond ( 'MaterialID' , $ tableMaterialIds ) -> cond ( 'Active' , 1 ) -> order_by ( 'priority' , 'DESC' ) -> join ( 'materialfield' ) -> first ( $ material ) ) { return $ material -> priority ; } return 0 ; } | Get max priority by current structure |
25,238 | public function __async_quantityFieldsRow ( $ structureId , $ entityID ) { $ structureFields = null ; if ( $ this -> query -> className ( 'field' ) -> join ( 'structurefield' ) -> cond ( 'StructureID' , $ structureId ) -> exec ( $ structureFields ) ) { $ fields = array ( ) ; foreach ( $ structureFields as $ field ) { $ fields [ $ field -> id ] = $ field ; } $ countOfFields = $ this -> query -> className ( 'material' ) -> cond ( 'parent_id' , $ entityID ) -> cond ( 'type' , 3 ) -> cond ( 'materialfield.FieldID' , array_keys ( $ fields ) ) -> cond ( 'Active' , 1 ) -> join ( 'materialfield' ) -> group_by ( 'MaterialID' ) -> count ( ) ; return array ( 'status' => 1 , 'countOfFields' => $ countOfFields ) ; } else { return array ( 'status' => 0 ) ; } } | Update quantity fields table row |
25,239 | public function __async_add ( $ materialId , $ structureId , $ afterAction , $ afterMaterialId , $ afterStructureId ) { $ material = null ; if ( $ this -> query -> className ( '\samson\cms\CMSMaterial' ) -> cond ( 'MaterialID' , $ materialId ) -> first ( $ material ) ) { $ structureIds = $ this -> query -> className ( 'structurematerial' ) -> cond ( 'MaterialID' , $ material -> id ) -> fields ( 'StructureID' ) ; $ structures = $ this -> query -> className ( 'structure' ) -> cond ( 'StructureID' , $ structureIds ) -> exec ( ) ; if ( ! empty ( $ structures ) ) { foreach ( $ structures as $ structure ) { if ( isset ( $ structure -> StructureID ) && ( $ structure -> StructureID == $ structureId ) ) { $ socialModule = m ( 'social' ) ; $ user = $ socialModule -> user ( ) ; $ maxPriority = $ this -> getMaxPriority ( $ materialId , $ structureId ) ; $ tableMaterial = new \ samson \ cms \ CMSMaterial ( false ) ; $ tableMaterial -> type = 3 ; $ tableMaterial -> Name = $ structure -> Name ; $ tableMaterial -> Url = $ structure -> Name . '-' . md5 ( date ( 'Y-m-d-h-i-s' ) ) ; $ tableMaterial -> parent_id = $ material -> MaterialID ; $ tableMaterial -> Published = 1 ; $ tableMaterial -> Active = 1 ; $ tableMaterial -> priority = $ maxPriority + 1 ; $ tableMaterial -> UserID = $ user -> id ; $ tableMaterial -> Created = date ( 'Y-m-d H:m:s' ) ; $ tableMaterial -> Modyfied = $ tableMaterial -> Created ; $ tableMaterial -> save ( ) ; $ structureMaterial = new \ samson \ cms \ CMSNavMaterial ( false ) ; $ structureMaterial -> StructureID = $ structureId ; $ structureMaterial -> MaterialID = $ tableMaterial -> MaterialID ; $ structureMaterial -> Active = 1 ; $ structureMaterial -> save ( ) ; } } $ result = $ this -> __async_table ( $ afterMaterialId , $ afterStructureId ) ; Event :: fire ( 'samson.cms.web.materialtable.add' , array ( $ material -> id , $ structureId ) ) ; return $ result ; } } return array ( 'status' => 0 ) ; } | Creating new material table row |
25,240 | public function __async_delete ( $ id , $ afterAction , $ afterMaterialId , $ afterStructureId ) { $ result = array ( 'status' => false ) ; $ material = null ; if ( $ this -> query -> className ( '\samson\cms\CMSMaterial' ) -> id ( $ id ) -> first ( $ material ) ) { $ material -> deleteWithRelations ( ) ; Event :: fire ( 'samson.cms.web.materialtable.delete' , array ( $ material -> parent_id ) ) ; $ result = $ this -> __async_table ( $ afterMaterialId , $ afterStructureId ) ; } return $ result ; } | Controller for deleting row from material table |
25,241 | public function __async_copy ( $ id , $ afterAction , $ afterMaterialId , $ afterStructureId ) { $ result = array ( 'status' => false ) ; $ material = null ; if ( $ this -> query -> className ( '\samson\cms\CMSMaterial' ) -> id ( $ id ) -> first ( $ material ) ) { $ copy = $ material -> copy ( ) ; $ copy -> save ( ) ; $ result [ 'status' ] = true ; $ result = $ this -> __async_table ( $ afterMaterialId , $ afterStructureId ) ; } return $ result ; } | Controller for copying row from material table |
25,242 | public function __async_table ( $ materialId , $ structureId ) { $ result = array ( 'status' => false ) ; $ structure = $ this -> query -> className ( '\samson\cms\Navigation' ) -> cond ( 'StructureID' , $ structureId ) -> first ( ) ; $ material = $ this -> query -> className ( '\samson\cms\Material' ) -> cond ( 'MaterialID' , $ materialId ) -> first ( ) ; if ( isset ( $ structureId ) ) { $ tab = new MaterialTable ( $ this , $ this -> query -> className ( '\samson\cms\CMSMaterial' ) , $ material , $ structure ) ; $ content = $ tab -> content ( ) ; Event :: fire ( 'samson.cms.web.materialtable.get.table' , array ( $ materialId , $ structureId , & $ content ) ) ; $ result [ 'status' ] = true ; $ result [ 'table' ] = $ content ; } return $ result ; } | Async updating material table |
25,243 | public function getMaterialTableTable ( $ materialId , $ structure , $ locale = '' ) { $ material = null ; if ( $ this -> query -> className ( '\samson\cms\CMSMaterial' ) -> cond ( 'MaterialID' , $ materialId ) -> first ( $ material ) ) { $ table = new MaterialTableTable ( $ material , null , $ structure , $ locale ) ; $ all = false ; $ multilingual = false ; if ( $ this -> query -> className ( '\samson\cms\CMSNavMaterial' ) -> cond ( 'MaterialID' , $ materialId ) -> join ( 'structure' ) -> cond ( 'StructureID' , $ structure -> StructureID ) -> first ( ) ) { if ( $ this -> query -> className ( 'structurefield' ) -> cond ( 'StructureID' , $ structure -> StructureID ) -> join ( 'field' ) -> cond ( 'field_local' , 0 ) -> first ( ) ) { $ all = true ; } if ( $ this -> query -> className ( 'structurefield' ) -> cond ( 'StructureID' , $ structure -> StructureID ) -> join ( 'field' ) -> cond ( 'field_local' , 1 ) -> first ( ) ) { $ multilingual = true ; } } return $ this -> view ( 'tab_view' ) -> set ( $ table -> render ( ) , 'table' ) -> set ( $ materialId , 'materialId' ) -> set ( $ structure -> StructureID , 'structureId' ) -> output ( ) ; } return '' ; } | Function to generate new table |
25,244 | static function hasKey ( string $ key ) : bool { self :: ensureKeyMapLoaded ( ) ; return isset ( self :: $ keyMap [ static :: class ] [ $ key ] ) ; } | Check if the given key exists in this enum |
25,245 | static function findValue ( string $ key ) { return self :: hasKey ( $ key ) ? self :: $ keyToValueMap [ static :: class ] [ $ key ] : null ; } | Attempt to find a value by its key . Returns NULL on failure . |
25,246 | static function findKey ( $ value ) : ? string { return self :: hasValue ( $ value ) ? self :: $ valueToKeyMap [ static :: class ] [ $ value ] : null ; } | Attempt to find a key by its value . Returns NULL on failure . |
25,247 | static function ensureKey ( string $ key ) { if ( ! self :: hasKey ( $ key ) ) { throw new InvalidKeyException ( sprintf ( 'The key "%s" is not defined in enum class "%s", known keys: %s' , $ key , static :: class , implode ( ', ' , self :: getKeys ( ) ) ) ) ; } } | Ensure that a key exists |
25,248 | static function ensureValue ( $ value ) { if ( ! self :: hasValue ( $ value ) ) { throw new InvalidValueException ( sprintf ( 'The value %s is not defined in enum class "%s", known values: %s' , self :: dumpValue ( $ value ) , static :: class , implode ( ', ' , array_map ( [ static :: class , 'dumpValue' ] , self :: getValues ( ) ) ) ) ) ; } } | Ensure that a value exists |
25,249 | protected static function determineKeyToValueMap ( ) : array { $ keyToValueMap = [ ] ; foreach ( ( new \ ReflectionClass ( static :: class ) ) -> getReflectionConstants ( ) as $ constant ) { if ( $ constant -> isPublic ( ) ) { $ keyToValueMap [ $ constant -> name ] = $ constant -> getValue ( ) ; } } return $ keyToValueMap ; } | Determine keys and values containing in this enum |
25,250 | public static function getAccountNameSuffix ( $ type_code ) { switch ( $ type_code ) { case Account :: TYPE_ACCOUNTS_RECEIVABLE : return ' A/R' ; case Account :: TYPE_ACCOUNTS_PAYABLE : return ' A/P' ; case Account :: TYPE_SALES : return ' Sales' ; case Account :: TYPE_BANK : return ' Bank' ; default : throw new \ Exception ( 'Incorrect type_code: ' . $ type_code ) ; } } | Get account name suffix |
25,251 | public function copyChildren ( $ targetDir ) { $ info = new \ SplFileInfo ( $ targetDir ) ; if ( ! $ info -> isDir ( ) ) { throw new InvalidArgumentException ( sprintf ( 'Target dir not found' ) ) ; } if ( ! $ info -> isReadable ( ) ) { throw new InvalidArgumentException ( sprintf ( 'Target dir not readable' ) ) ; } if ( ! $ info -> isWritable ( ) ) { throw new InvalidArgumentException ( sprintf ( 'Target dir not writable' ) ) ; } $ files = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ this -> dir , \ FilesystemIterator :: SKIP_DOTS ) , \ RecursiveIteratorIterator :: SELF_FIRST ) ; foreach ( $ files as $ info ) { $ sourcePathname = $ info -> getPathname ( ) ; $ subdirPathname = $ this -> subtractBasedir ( $ sourcePathname , $ this -> dir ) ; $ targetPathname = sprintf ( '%s/%s' , $ targetDir , $ subdirPathname ) ; if ( $ info -> isDir ( ) ) { mkdir ( $ targetPathname ) ; } else { copy ( $ sourcePathname , $ targetPathname ) ; } } } | Copy the children of this directory into targetDir |
25,252 | public function moveChildren ( $ targetDir ) { $ info = new \ SplFileInfo ( $ targetDir ) ; if ( ! $ info -> isDir ( ) ) { throw new InvalidArgumentException ( sprintf ( 'Target dir not found' ) ) ; } if ( ! $ info -> isReadable ( ) ) { throw new InvalidArgumentException ( sprintf ( 'Target dir not readable' ) ) ; } if ( ! $ info -> isWritable ( ) ) { throw new InvalidArgumentException ( sprintf ( 'Target dir not writable' ) ) ; } foreach ( new \ DirectoryIterator ( $ this -> dir ) as $ info ) { if ( $ info -> isDot ( ) ) { continue ; } $ sourcePathname = $ info -> getPathname ( ) ; $ subdirPathname = $ this -> subtractBasedir ( $ sourcePathname , $ this -> dir ) ; $ targetPathname = sprintf ( '%s/%s' , $ targetDir , $ subdirPathname ) ; rename ( $ sourcePathname , $ targetPathname ) ; } } | Move the children of this directory into targetDir |
25,253 | public function extendBlock ( $ blockName , Closure $ closure ) { $ blockName = ucfirst ( strtolower ( $ blockName ) ) ; $ methodName = camel_case ( "block_{$blockName}" ) ; return $ this -> bindElementClosure ( $ methodName , $ closure ) ; } | Adds a Block closure that handles the start of an element . |
25,254 | public function extendInline ( $ inlineName , Closure $ closure ) { $ blockName = ucfirst ( strtolower ( $ inlineName ) ) ; $ methodName = camel_case ( "inline_{$inlineName}" ) ; return $ this -> bindElementClosure ( $ methodName , $ closure ) ; } | Adds an Inline closure that handles the entirety of an inline element . |
25,255 | protected function bindElementClosure ( $ methodName , Closure $ closure ) { $ this -> elementClosures [ $ methodName ] = $ closure -> bindTo ( $ this ) ; return $ this ; } | Adds a closure that handles the start of an element . |
25,256 | public function addInlineType ( $ Marker , $ Type ) { if ( ! isset ( $ this -> InlineTypes [ $ Marker ] ) ) { $ this -> InlineTypes [ $ Marker ] = [ ] ; $ this -> inlineMarkerList .= $ Marker ; } $ InlineTypes = & $ this -> InlineTypes [ $ Marker ] ; array_unshift ( $ InlineTypes , $ Type ) ; return $ this ; } | Extends the inline parser dictionary . |
25,257 | public function addBlockType ( $ Marker , $ Type ) { if ( ! isset ( $ this -> BlockTypes [ $ Marker ] ) ) { $ this -> BlockTypes [ $ Marker ] = [ ] ; } $ BlockTypes = & $ this -> BlockTypes [ $ Marker ] ; array_unshift ( $ BlockTypes , $ Type ) ; return $ this ; } | Extends the block parser dictionary . |
25,258 | public function removeInlineByMarker ( $ element ) { $ this -> disableElementInArray ( $ marker , $ this -> InlineTypes , $ this -> inlineMarkerList ) ; return $ this ; } | Removes any reference to this inline marker in Parsedown . |
25,259 | protected function loadModel ( $ id = null ) { $ modelClass = $ this -> modelClass ( ) ; if ( $ id ) { $ this -> modelInstance = $ modelClass :: findOne ( $ id ) ; } else { $ this -> modelInstance = new $ modelClass ( ) ; } $ this -> modelInstance -> load ( $ this -> attributes , '' ) ; return $ this -> modelInstance ; } | load model instance . |
25,260 | public function render ( ) { $ html = parent :: render ( ) ; $ items = '' ; if ( $ this -> currentPage > 1 ) { $ first = $ this -> getElementTemplate ( 'first' ) ; $ first = str_replace ( '%page%' , 1 , $ first ) ; $ items .= $ first ; } if ( $ this -> currentPage > 1 ) { $ prev = $ this -> getElementTemplate ( 'previous' ) ; $ prev = str_replace ( '%page%' , $ this -> currentPage - 1 , $ prev ) ; $ items .= $ prev ; } $ startPage = $ this -> currentPage - floor ( $ this -> maxShowedPages / 2 ) ; $ endPage = $ this -> currentPage + floor ( $ this -> maxShowedPages / 2 ) ; if ( $ startPage < 1 ) { $ endPage += ( 1 - $ startPage ) ; $ startPage = 1 ; } if ( $ endPage > $ this -> nbPages ) { $ endPage = $ this -> nbPages ; } if ( ( $ endPage - $ startPage + 1 ) != $ this -> maxShowedPages ) { $ startPage = $ endPage - $ this -> maxShowedPages + 1 ; if ( $ startPage < 1 ) { $ startPage = 1 ; } } for ( $ i = $ startPage ; $ i <= $ endPage ; $ i ++ ) { if ( $ this -> currentPage == $ i ) { $ page = $ this -> getElementTemplate ( 'selectedpage' ) ; } else { $ page = $ this -> getElementTemplate ( 'page' ) ; } $ page = str_replace ( '%page%' , $ i , $ page ) ; $ items .= $ page ; } if ( $ this -> currentPage < $ this -> nbPages ) { $ next = $ this -> getElementTemplate ( 'next' ) ; $ next = str_replace ( '%page%' , $ this -> currentPage + 1 , $ next ) ; $ items .= $ next ; } if ( $ this -> currentPage != $ this -> nbPages && $ this -> nbPages > 0 ) { $ last = $ this -> getElementTemplate ( 'last' ) ; $ last = str_replace ( '%page%' , $ this -> nbPages , $ last ) ; $ items .= $ last ; } $ html = str_replace ( '%items%' , $ items , $ html ) ; return $ html ; } | Effectue un rendu du composant |
25,261 | public function reset ( $ component ) { if ( is_string ( $ component ) ) { $ component = $ this -> laravel [ 'components' ] -> findOrFail ( $ component ) ; } $ migrator = new Migrator ( $ component ) ; $ database = $ this -> option ( 'database' ) ; if ( ! empty ( $ database ) ) { $ migrator -> setDatabase ( $ database ) ; } $ migrated = $ migrator -> reset ( ) ; if ( count ( $ migrated ) ) { foreach ( $ migrated as $ migration ) { $ this -> line ( "Rollback: <info>{$migration}</info>" ) ; } return ; } $ this -> comment ( 'Nothing to rollback.' ) ; } | Rollback migration from the specified component . |
25,262 | public function table ( $ table ) { if ( ! isset ( $ this -> tables [ $ table ] ) ) { $ this -> tables [ $ table ] = new Table ( $ table , $ this -> storage ) ; } return new QueryBuilder ( $ this -> tables [ $ table ] , $ this -> filters ) ; } | Get a new query builder for the table |
25,263 | public static function register ( $ directory , $ first = true ) { if ( $ first ) { self :: $ scannedDirectories [ ] = $ directory ; } $ directory = trim ( $ directory , '/' ) ; $ dir = dir ( trim ( $ directory ) ) ; while ( false !== $ file = $ dir -> read ( ) ) { if ( $ file !== '.' && $ file !== '..' ) { if ( is_dir ( $ directory . DIRECTORY_SEPARATOR . $ file ) ) { self :: register ( $ directory . DIRECTORY_SEPARATOR . $ file , false ) ; } elseif ( is_file ( $ directory . DIRECTORY_SEPARATOR . $ file ) ) { self :: _asd ( $ directory , $ file ) ; } } } $ dir -> close ( ) ; } | Register the directory for the Autoloader . Scan all files inside the directory recursively and buffer them in the classes property . |
25,264 | public static function load ( $ class ) { if ( array_key_exists ( $ class , self :: $ classes ) && is_file ( self :: $ classes [ $ class ] ) ) { require_once self :: $ classes [ $ class ] ; } elseif ( array_key_exists ( 'Alcys\\' . $ class , self :: $ classes ) && is_file ( self :: $ classes [ $ class ] ) ) { require_once self :: $ classes [ 'Alcys\\' . $ class ] ; } } | This method will call when the system try to instantiate a not included class or interface . The parsed class name should exist as key . If this is the case the class will required . |
25,265 | protected function mapAddressListToArray ( Mail \ AddressList $ addresses , $ type = 'to' ) { $ array = [ ] ; foreach ( $ addresses as $ address ) { $ array [ ] = [ 'email' => $ address -> getEmail ( ) , 'name' => $ address -> getName ( ) , 'type' => $ type ] ; } return $ array ; } | Map Address List to Mandrill array |
25,266 | public function getUrl ( Repo $ repo ) { return $ this -> helper -> getUrl ( $ repo -> getSlug ( ) , $ repo -> getType ( ) ) ; } | Get Repo url |
25,267 | public function getQualityBadge ( Repo $ repo ) { if ( $ repo -> getQualityBadgeHash ( ) ) { return sprintf ( '<img src="%s" />' , $ this -> helper -> getQualityBadgeUrl ( $ repo -> getSlug ( ) , $ repo -> getType ( ) , $ repo -> getQualityBadgeHash ( ) ) ) ; } return '' ; } | Get Repo quality badge |
25,268 | public function getCoverageBadge ( Repo $ repo ) { if ( $ repo -> getCoverageBadgeHash ( ) ) { return sprintf ( '<img src="%s" />' , $ this -> helper -> getCoverageBadgeUrl ( $ repo -> getSlug ( ) , $ repo -> getType ( ) , $ repo -> getCoverageBadgeHash ( ) ) ) ; } return '' ; } | Get Repo coverage badge |
25,269 | public function __async_removenav ( $ materialId = null , $ navigation = null ) { $ structureMaterials = dbQuery ( 'structurematerial' ) -> cond ( 'MaterialID' , $ materialId ) -> cond ( 'StructureID' , $ navigation ) -> first ( ) ; $ structureMaterials -> delete ( ) ; } | Delete structure from entity |
25,270 | public function __async_addnav ( $ materialId = null , $ navigation = null ) { $ sm = new NavigationMaterial ( ) ; $ sm -> MaterialID = $ materialId ; $ sm -> StructureID = $ navigation ; $ sm -> Active = '1' ; $ sm -> save ( ) ; } | Add new structure to entity |
25,271 | public function __async_collection ( $ navigationId = '0' , $ search = '0' , $ page = 1 ) { if ( isset ( $ _GET [ 'pagerSize' ] ) ) { $ _SESSION [ 'pagerSize' ] = str_replace ( '/' , '' , $ _GET [ 'pagerSize' ] ) ; unset ( $ _GET [ 'pagerSize' ] ) ; } if ( isset ( $ _GET [ 'search' ] ) ) { $ _SESSION [ 'search' ] = str_replace ( '/' , '' , $ _GET [ 'search' ] ) ; $ search = str_replace ( '/' , '' , $ _GET [ 'search' ] ) ; unset ( $ _GET [ 'search' ] ) ; } $ navigationId = isset ( $ navigationId ) ? $ navigationId : '0' ; $ search = ! empty ( $ search ) ? urldecode ( $ search ) : 0 ; $ page = isset ( $ page ) ? $ page : 1 ; $ pager = new Pager ( $ page , isset ( $ _SESSION [ 'pagerSize' ] ) ? $ _SESSION [ 'pagerSize' ] : $ this -> pageSize , $ this -> id . '/' . self :: VIEW_TABLE_NAME . '/' . $ navigationId . '/' . $ search ) ; $ collection = new $ this -> collectionClass ( $ this , new dbQuery ( ) , $ pager ) ; if ( isset ( $ navigationId ) && ! empty ( $ navigationId ) ) { $ collection = $ collection -> navigation ( array ( $ navigationId ) ) ; } return array_merge ( array ( 'status' => true , 'navigationId' => $ navigationId , 'searchQuery' => $ search , 'pageNumber' => $ page , 'rowsCount' => $ collection -> search ( $ search ) -> fill ( ) -> getSize ( ) ) , $ collection -> search ( $ search ) -> fill ( ) -> toView ( self :: VIEW_TABLE_NAME . '_' ) ) ; } | Render materials list with pager |
25,272 | public function __async_form ( $ identifier = null ) { $ result = array ( 'status' => false ) ; $ entity = null ; if ( $ this -> findAsyncEntityByID ( $ identifier , $ entity , $ result ) ) { $ form = new $ this -> formClassName ( $ this , $ this -> query -> className ( $ this -> entity ) , $ entity ) ; $ result [ 'form' ] = $ form -> render ( ) ; $ result [ 'entity' ] = $ entity ; if ( isset ( $ form -> tabs [ 0 ] -> activeButton ) ) { $ result [ 'activeButton' ] = $ form -> tabs [ 0 ] -> activeButton ; } } return $ result ; } | Asynchronous material entity form rendering action |
25,273 | public function __tocsv ( $ structureId = null ) { $ pager = new Pager ( 0 ) ; $ collection = new $ this -> collectionClass ( $ this , new dbQuery ( ) , $ pager ) ; if ( isset ( static :: $ navigation ) ) { $ collection = $ collection -> navigation ( static :: $ navigation ) ; } else { $ collection = $ collection -> navigation ( array ( $ structureId ) ) ; } $ collection -> fill ( ) ; $ this -> tocsv ( $ collection ) ; } | Get current materials in csv format |
25,274 | public function main ( ) { $ mainPageHTML = '' ; $ dbMaterials = array ( ) ; if ( dbQuery ( 'samsoncms\api\Material' ) -> join ( 'user' ) -> cond ( 'Active' , 1 ) -> cond ( 'Draft' , 0 ) -> order_by ( 'Created' , 'DESC' ) -> cond ( 'Name' , "" , dbRelation :: NOT_EQUAL ) -> limit ( 5 ) -> exec ( $ dbMaterials ) ) { $ rowsHTML = '' ; foreach ( $ dbMaterials as $ dbMaterial ) { $ rowsHTML .= $ this -> view ( 'main/row' ) -> set ( $ dbMaterial , 'material' ) -> set ( isset ( $ dbMaterial -> onetoone [ '_user' ] ) ? $ dbMaterial -> onetoone [ '_user' ] : array ( ) , 'user' ) -> output ( ) ; } for ( $ i = sizeof ( $ dbMaterials ) ; $ i < 5 ; $ i ++ ) { $ rowsHTML .= $ this -> view ( 'main/row' ) -> output ( ) ; } $ mainPageHTML = $ this -> view ( 'main/index' ) -> set ( $ rowsHTML , 'rows' ) -> output ( ) ; } return $ mainPageHTML ; } | Output for main page |
25,275 | public function createService ( ServiceLocatorInterface $ serviceLocator ) { $ config = $ serviceLocator -> get ( 'Configuration' ) ; $ srvConfig = isset ( $ config [ 'modules' ] [ 'Grid\Core' ] [ 'settings' ] ) ? ( array ) $ config [ 'modules' ] [ 'Grid\Core' ] [ 'settings' ] : array ( ) ; return new Definitions ( $ srvConfig ) ; } | Create the definitions - service |
25,276 | public function listen ( $ interval = 5 , $ timeout = 0 ) { while ( true ) { if ( $ manager = $ this -> getManager ( $ timeout ) ) { $ manager -> execute ( ) ; } elseif ( $ interval > 0 ) { $ this -> sleep ( $ interval ) ; } } } | Listens to queue |
25,277 | protected function getManager ( $ timeout = 0 ) { try { $ manager = $ this -> connector -> pop ( $ this -> queue , $ timeout ) ; } catch ( JobNotFoundException $ e ) { $ this -> connector -> delete ( $ manager ) ; return false ; } catch ( QueueEmptyException $ e ) { return false ; } if ( $ manager instanceof LoggerAwareInterface ) { $ manager -> setLogger ( $ this -> logger ) ; } return $ manager ; } | Returns a ManagerInterface |
25,278 | public static function isValidXmlFragment ( $ xml , $ doc = null ) { if ( $ doc == null ) { $ doc = new DOMDocument ( "1.0" , "ISO-8859-1" ) ; } $ fragment = $ doc -> createDocumentFragment ( ) ; @ $ fragment -> appendXML ( $ xml ) ; $ node = @ $ doc -> appendChild ( $ fragment ) ; return $ node !== false ; } | Is a valid XML fragment? |
25,279 | public static function isValidXml ( $ xml , $ doc = null ) { if ( $ doc == null ) { $ doc = new DOMDocument ( "1.0" , "ISO-8859-1" ) ; } $ useInternalErrors = libxml_use_internal_errors ( true ) ; $ doc -> loadXML ( $ xml ) ; $ errors = libxml_get_errors ( ) ; libxml_use_internal_errors ( $ useInternalErrors ) ; return count ( $ errors ) == 0 ; } | Is a valid XML document? |
25,280 | public static function dom2str ( $ node ) { $ doc = $ node instanceof DOMDocument ? $ node : $ node -> ownerDocument ; return $ doc -> saveXML ( $ node ) ; } | Gets the string representation of a node . |
25,281 | public static function getChildElements ( $ node ) { $ ret = array ( ) ; $ nodes = $ node -> childNodes ; foreach ( $ nodes as $ node ) { if ( $ node instanceof DOMElement ) { array_push ( $ ret , $ node ) ; } } return $ ret ; } | Gets child elements of a given node . |
25,282 | public static function getElementsByTagName ( $ node , $ tagName ) { $ ret = array ( ) ; $ nodes = $ node -> getElementsByTagName ( $ tagName ) ; foreach ( $ nodes as $ node ) { if ( $ node instanceof DOMElement ) { array_push ( $ ret , $ node ) ; } } return $ ret ; } | Gets elements by tagname . |
25,283 | public static function searchNode ( $ node , $ items , $ offset = 0 ) { $ len = count ( $ items ) ; for ( $ i = $ offset ; $ i < $ len ; $ i ++ ) { $ item = $ items [ $ i ] ; if ( $ item -> isSameNode ( $ node ) ) { return $ i ; } } return false ; } | Searches a node in a list . |
25,284 | public static function mergeNodes ( $ items1 , $ items2 ) { $ ret = array ( ) ; $ items = array_merge ( $ items1 , $ items2 ) ; $ len = count ( $ items ) ; for ( $ i = 0 ; $ i < $ len ; $ i ++ ) { $ item = $ items [ $ i ] ; $ position = Dom :: searchNode ( $ item , $ items , $ i + 1 ) ; if ( $ position === false ) { array_push ( $ ret , $ item ) ; } } return $ ret ; } | Merges two lists of nodes in a single list . |
25,285 | public static function sortNodes ( $ nodes ) { foreach ( $ nodes as $ node ) { if ( ! isset ( $ node -> __path__ ) ) { $ node -> __path__ = Dom :: _getNodePath ( $ node ) ; } } usort ( $ nodes , function ( $ node0 , $ node1 ) { $ path0 = $ node0 -> __path__ ; $ path1 = $ node1 -> __path__ ; $ count0 = count ( $ path0 ) ; $ count1 = count ( $ path1 ) ; $ len = min ( $ count0 , $ count1 ) ; for ( $ i = 0 ; $ i < $ len ; $ i ++ ) { if ( $ path0 [ $ i ] != $ path1 [ $ i ] ) { return $ path0 [ $ i ] > $ path1 [ $ i ] ; } } return $ count0 > $ count1 ; } ) ; foreach ( $ nodes as $ node ) { unset ( $ node -> __path__ ) ; } return $ nodes ; } | Sort nodes in the same order they appear in the document . |
25,286 | private static function _getNodePath ( $ node ) { $ ret = array ( ) ; $ doc = $ node -> ownerDocument ; $ parentNode = $ node -> parentNode ; while ( $ parentNode !== null && ! $ doc -> isSameNode ( $ parentNode ) ) { $ pos = 0 ; foreach ( $ parentNode -> childNodes as $ i => $ childNode ) { if ( $ childNode -> isSameNode ( $ node ) ) { $ pos = $ i ; break ; } } array_unshift ( $ ret , $ pos ) ; $ node = $ parentNode ; $ parentNode = $ node -> parentNode ; } return $ ret ; } | Gets the node path . |
25,287 | protected function fieldAddRaw ( $ name , $ type , $ params = array ( ) ) { if ( empty ( $ name ) ) { return false ; } $ fldobj = ( object ) $ params ; $ fldobj -> name = $ name ; $ fldobj -> type = $ type ; $ this -> fields [ $ name ] = $ fldobj ; } | Add field into fields list . |
25,288 | protected function loadItem ( & $ obj , $ item ) { switch ( $ item ) { case 'id' : $ this -> id = ( int ) $ obj [ 'id' ] ; return true ; case 'published' : $ this -> published = $ obj [ 'published' ] ; return true ; case 'name' : $ this -> name_ru = $ obj [ 'name_ru' ] ; $ this -> name_ua = $ obj [ 'name_ua' ] ; return true ; case 'alias' : $ this -> alias_ru = $ obj [ 'alias_ru' ] ; $ this -> alias_ua = $ obj [ 'alias_ua' ] ; return true ; case 'created' : $ this -> created = new \ Brilliant \ BDateTime ( $ obj [ 'created' ] ) ; return true ; case 'modified' : $ this -> modified = new \ Brilliant \ BDateTime ( $ obj [ 'modified' ] ) ; return true ; } return false ; } | Load item by type |
25,289 | public function saveToDB ( ) { BLog :: addToLog ( '[Items.Item.' . $ this -> tableName . ']: saveToDB()' ) ; if ( $ this -> isNew ) { return $ this -> dbInsert ( ) ; } else { return $ this -> dbupdate ( ) ; } } | Check is and run insert or update query reload cache . |
25,290 | public function setDeadline ( $ deadline , $ timeout ) { $ this -> deadline = $ deadline ; $ this -> timeout = $ timeout ; return $ this ; } | Sets request deadline |
25,291 | protected function checkTimeout ( ) { $ info = stream_get_meta_data ( $ this -> socket ) ; if ( $ info [ 'timed_out' ] || $ this -> deadline && time ( ) > $ this -> deadline ) { $ reason = $ this -> deadline ? "after {$this->timeout} second(s)" : 'due to default_socket_timeout php.ini setting' ; throw new Net_Notifier_Socket_TimeoutException ( "Request timed out {$reason}" ) ; } } | Throws an exception if stream timed out |
25,292 | public function csrf_verify ( ) { if ( count ( $ _POST ) == 0 ) { return $ this -> csrf_set_cookie ( ) ; } if ( ! isset ( $ _POST [ $ this -> _csrf_token_name ] ) or ! isset ( $ _COOKIE [ $ this -> _csrf_cookie_name ] ) ) { $ this -> csrf_show_error ( ) ; } if ( $ _POST [ $ this -> _csrf_token_name ] != $ _COOKIE [ $ this -> _csrf_cookie_name ] ) { $ this -> csrf_show_error ( ) ; } unset ( $ _POST [ $ this -> _csrf_token_name ] ) ; unset ( $ _COOKIE [ $ this -> _csrf_cookie_name ] ) ; $ this -> _csrf_set_hash ( ) ; $ this -> csrf_set_cookie ( ) ; return $ this ; } | Verify Cross Site Request Forgery Protection |
25,293 | public function xss_hash ( ) { if ( $ this -> _xss_hash == '' ) { mt_srand ( ) ; $ this -> _xss_hash = md5 ( time ( ) + mt_rand ( 0 , 1999999999 ) ) ; } return $ this -> _xss_hash ; } | Random Hash for protecting URLs |
25,294 | protected function _validate_entities ( $ str ) { $ str = preg_replace ( '|\&([a-z\_0-9\-]+)\=([a-z\_0-9\-]+)|i' , $ this -> xss_hash ( ) . "\\1=\\2" , $ str ) ; $ str = preg_replace ( '#(&\#?[0-9a-z]{2,})([\x00-\x20])*;?#i' , "\\1;\\2" , $ str ) ; $ str = preg_replace ( '#(&\#x?)([0-9A-F]+);?#i' , "\\1\\2;" , $ str ) ; $ str = str_replace ( $ this -> xss_hash ( ) , '&' , $ str ) ; return $ str ; } | Validate URL entities |
25,295 | public static function setup ( $ enablePsr = true , $ enablePrefixes = true , $ enableClasses = true ) { if ( $ enableClasses ) { spl_autoload_register ( [ self :: $ instance , 'load' ] ) ; } if ( $ enablePrefixes ) { self :: registerPrefix ( 'J' , JPATH_PLATFORM . '/joomla' ) ; spl_autoload_register ( [ self :: $ instance , '_autoload' ] ) ; } if ( $ enablePsr ) { spl_autoload_register ( [ self :: $ instance , 'loadByPsr0' ] ) ; spl_autoload_register ( [ self :: $ instance , 'loadByAlias' ] ) ; } } | Method to setup the autoloaders for the Joomla Platform . Since the SPL autoloaders are called in a queue we will add our explicit class - registration based loader first then fall back on the autoloader based on conventions . This will allow people to register a class in a specific location and override platform libraries as was previously possible . |
25,296 | private static function _autoload ( $ class ) { $ realClass = $ class ; if ( preg_match ( '/^JProxy_/i' , $ class ) ) { $ class = preg_replace ( '/^JProxy_/i' , '' , $ class ) ; } foreach ( self :: $ prefixes as $ prefix => $ lookup ) { $ chr = strlen ( $ prefix ) < strlen ( $ class ) ? $ class [ strlen ( $ prefix ) ] : 0 ; if ( strpos ( $ class , $ prefix ) === 0 && ( $ chr === strtoupper ( $ chr ) ) ) { $ existsBefore = class_exists ( $ realClass , false ) ; if ( $ realClass === $ class ) { self :: loadByAlias ( $ realClass ) ; self :: load ( $ realClass ) ; } $ return = true ; if ( ! $ existsBefore && ! class_exists ( $ class , false ) ) { $ return = self :: _load ( substr ( $ class , strlen ( $ prefix ) ) , $ lookup ) ; } if ( $ realClass === $ class && ! $ existsBefore && class_exists ( $ realClass , false ) ) { self :: injectStaticDependencies ( $ class ) ; } return $ return ; } } return false ; } | Autoload a class based on name . |
25,297 | private static function _load ( $ class , array $ lookup ) { $ parts = preg_split ( '/(?<=[a-z0-9])(?=[A-Z])/x' , $ class ) ; $ partsCount = count ( $ parts ) ; foreach ( $ lookup as $ base ) { $ path = $ base . '/' . implode ( '/' , array_map ( 'strtolower' , $ parts ) ) . '.php' ; if ( file_exists ( $ path ) ) { return include $ path ; } if ( $ partsCount === 1 ) { $ path = $ base . '/' . implode ( '/' , array_map ( 'strtolower' , array ( $ parts [ 0 ] , $ parts [ 0 ] ) ) ) . '.php' ; if ( file_exists ( $ path ) ) { return include $ path ; } } } return false ; } | Load a class based on name and lookup array . |
25,298 | public function append ( $ road ) { if ( ! in_array ( $ road -> getName ( ) , $ this -> priorityQueue ) ) { $ this -> put ( $ road ) ; array_push ( $ this -> priorityQueue , $ road -> getName ( ) ) ; } return $ this ; } | Append a given resource road into this map . |
25,299 | public function prepend ( SourceRoad $ road ) { if ( ! in_array ( $ road -> getName ( ) , $ this -> priorityQueue ) ) { $ this -> put ( $ road ) ; array_unshift ( $ this -> priorityQueue , $ road -> getName ( ) ) ; } } | Prepend a SourceRoad to this roadMap . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.