idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
42,300 | public function fromRoute ( $ name , array $ params = [ ] ) { $ router = $ this -> getRouter ( ) ; $ route = $ router -> get ( $ name ) ; return $ route -> assemble ( $ params ) ; } | Gets url from route . |
42,301 | public function absolute ( $ relative = null ) { $ host = $ this -> getHost ( ) ; if ( null !== $ relative ) { $ relative = '/' . ltrim ( $ relative , '/' ) ; } return $ host . $ relative ; } | Gets the absolute address . |
42,302 | public function render ( ) { $ short = ! empty ( $ this -> detailed ) ? "<p><strong>{$this->short}</strong></p>" : "<p>{$this->short}</p>" ; $ detailed = ! empty ( $ this -> detailed ) ? "<p>{$this->detailed}</p>" : "" ; $ classes = implode ( ' ' , $ this -> getClasses ( ) ) ; return '<div class="' . $ classes . '">' . $ short . $ detailed . '</div>' ; } | Renders the log message to HTML markup |
42,303 | public function locate ( $ pack ) { $ finder = new Finder ( ) ; $ packDirectory = $ this -> packs [ $ pack ] -> getDirectory ( ) ; $ commandDir = $ packDirectory . DIRECTORY_SEPARATOR . "Command" ; if ( is_dir ( $ commandDir ) ) { foreach ( $ finder -> name ( "*.php" ) -> in ( $ packDirectory . DIRECTORY_SEPARATOR . "Command" ) as $ file ) { $ commandClass = str_replace ( '.php' , '' , $ file -> getFilename ( ) ) ; $ fullClassName = "\\" . $ this -> packs [ $ pack ] -> getNameSpace ( ) . "\\Command\\" . $ commandClass ; if ( class_exists ( $ fullClassName ) ) { $ command = new $ fullClassName ; if ( $ command instanceof \ Singular \ Console \ Command \ Command ) { $ this -> console -> add ( $ command ) ; } } } } } | Localiza a registra os comandos de um pacote automaticamente . |
42,304 | protected function stringifyBody ( ResponseInterface $ response ) : string { $ body = $ response -> getBody ( ) ; if ( $ body === null ) { return '' ; } return json_encode ( $ body , JSON_PARTIAL_OUTPUT_ON_ERROR ) ; } | Stringify response body to JSON string . |
42,305 | protected function addHeaders ( ResponseInterface $ response , string $ body ) : ResponseInterface { return $ response -> andHeader ( 'Content-Type' , 'application/json' ) -> andHeader ( 'Content-Length' , ( string ) strlen ( $ body ) ) ; } | Add Content - Length header to response . |
42,306 | public function hidden ( $ name , $ value = null , $ attributes = null ) { return '<input type="hidden" name="' . $ name . '" value="' . $ this -> getValue ( $ name , $ value ) . '" ' . ( ( $ attributes !== null ) ? $ this -> attributes ( $ attributes ) : "" ) . ' />' ; } | Generates hidden input for form |
42,307 | public function input ( $ name , $ value = null , $ attributes = null ) { return '<input type="text" name="' . $ name . '" value="' . $ this -> getValue ( $ name , $ value ) . '" ' . ( ( $ attributes !== null ) ? $ this -> attributes ( $ attributes ) : "" ) . '/>' ; } | Generates text input |
42,308 | public function password ( $ name , $ value = null , $ attributes = null ) { return '<input type="password" name="' . $ name . '" value="' . $ this -> getValue ( $ name , $ value ) . '" ' . ( ( $ attributes !== null ) ? $ this -> attributes ( $ attributes ) : "" ) . '/>' ; } | Generates password input |
42,309 | public function submit ( $ name , $ value = null , $ attributes = null ) { return '<input type="submit" name="' . $ name . '" ' . ( ( $ attributes !== null ) ? $ this -> attributes ( $ attributes ) : "" ) . ' value="' . $ this -> getValue ( $ name , $ value ) . '" />' ; } | Generates submit button |
42,310 | public function actionIndex ( ) { $ query = ArticleCategory :: find ( ) -> orderBy ( [ 'sort' => SORT_ASC ] ) ; $ dataProvider = new ActiveDataProvider ( [ 'query' => $ query , 'pagination' => false ] ) ; return $ this -> render ( 'index' , [ 'dataProvider' => $ dataProvider , ] ) ; } | Lists all Category models . |
42,311 | public function findOneByRole ( $ role ) { $ qb = $ this -> createQueryBuilder ( 'g' ) ; return $ qb -> andWhere ( $ qb -> expr ( ) -> like ( 'g.roles' , $ qb -> expr ( ) -> literal ( '%"' . strtoupper ( $ role ) . '"%' ) ) ) -> orderBy ( 'g.position' , 'DESC' ) -> setMaxResults ( 1 ) -> getQuery ( ) -> getOneOrNullResult ( ) ; } | Finds the lower privilege level group having the given role . |
42,312 | public function exists ( $ key ) { if ( ! array_key_exists ( $ key , $ this -> storage ) ) return false ; if ( $ this -> storage [ $ key ] [ 'expires' ] > 0 && time ( ) > $ this -> storage [ $ key ] [ 'expires' ] ) return false ; return true ; } | Checks if data exists in cache |
42,313 | public function getConfig ( ) { if ( $ this -> configuration ) { return $ this -> configuration ; } $ dir = APP_DIR . DS . 'Resource' . DS . 'migrations' ; $ migrationTable = 'phinxlog' ; if ( $ bundleName = $ this -> input -> getOption ( 'bundle' ) ) { $ dir = Bundles :: getPath ( $ bundleName ) . DS . 'Resource' . DS . 'migrations' ; } return $ this -> configuration = new Config ( [ 'paths' => [ 'migrations' => $ dir ] , 'environments' => [ 'default_migration_table' => $ migrationTable , 'default_database' => getenv ( 'RAD_ENVIRONMENT' ) , getenv ( 'RAD_ENVIRONMENT' ) => \ Rad \ Configure \ Config :: get ( 'migrations.environments.' . getenv ( 'RAD_ENVIRONMENT' ) ) ] ] ) ; } | Overrides the original method from phinx in order to return a tailored Config object containing the connection details for the database . |
42,314 | public static function image ( $ itemId , $ size ) { if ( has_post_thumbnail ( $ itemId ) ) { return wp_get_attachment_image_src ( get_post_thumbnail_id ( $ itemId ) , $ size ) [ 0 ] ; } return false ; } | Grab the URL for the featured image in a specific size . |
42,315 | public static function imageSizes ( $ size = false ) { global $ _wp_additional_image_sizes ; $ additionalSizes = $ _wp_additional_image_sizes ; $ sizes = [ ] ; $ imageSizes = get_intermediate_image_sizes ( ) ; foreach ( $ imageSizes as $ imageSize ) { if ( in_array ( $ imageSize , [ 'thumbnail' , 'medium' , 'large' ] ) ) { $ sizes [ $ imageSize ] = ( object ) [ 'name' => $ imageSize , 'width' => get_option ( $ imageSize . '_size_w' ) , 'height' => get_option ( $ imageSize . '_size_h' ) , 'crop' => ( bool ) get_option ( $ imageSize . '_crop' ) ] ; } elseif ( isset ( $ additionalSizes [ $ imageSize ] ) ) { $ sizes [ $ imageSize ] = ( object ) [ 'name' => $ imageSize , 'width' => $ additionalSizes [ $ imageSize ] [ 'width' ] , 'height' => $ additionalSizes [ $ imageSize ] [ 'height' ] , 'crop' => $ additionalSizes [ $ imageSize ] [ 'crop' ] ] ; } } if ( $ size ) { if ( isset ( $ sizes [ $ size ] ) ) { return $ sizes [ $ size ] ; } else { return false ; } } return $ sizes ; } | Create an array of all image sizes and their meta data . |
42,316 | public static function images ( $ id ) { $ sizes = self :: imageSizes ( ) ; $ urls = [ ] ; if ( has_post_thumbnail ( $ id ) ) { $ image = wp_get_attachment_image_src ( get_post_thumbnail_id ( $ id ) , 'full' ) ; $ image = pathinfo ( $ image [ 0 ] ) ; $ extension = $ image [ 'extension' ] ; $ image = $ image [ 'dirname' ] . '/' . $ image [ 'filename' ] ; $ urls [ 'full' ] = $ image . '.' . $ extension ; foreach ( $ sizes as $ size ) { $ urls [ Data :: spaceToCamelCase ( $ size -> name , '-' ) ] = $ image . '-' . $ size -> width . 'x' . $ size -> height . '.' . $ extension ; } return ( object ) $ urls ; } else { return false ; } } | Create an object casted array of the featured image in all sizes . |
42,317 | public function getQueryStatements ( $ table ) { $ query = array ( ) ; array_push ( $ query , $ this -> name . ' ' . $ this -> type ) ; if ( $ this -> nullable == false ) array_push ( $ query , ' NOT NULL' ) ; else array_push ( $ query , ' NULL' ) ; if ( isset ( $ this -> default_value ) ) { $ value = $ this -> default_value ; if ( $ this -> type == 'BOOL' ) $ value = ( $ this -> default_value ) ? 1 : 0 ; array_push ( $ query , " DEFAULT '$value'" ) ; } if ( $ this -> auto_increments && $ this -> type == 'INT' ) array_push ( $ query , ' AUTO_INCREMENT' ) ; if ( $ this -> primary ) array_push ( $ query , ",\n\t" . 'CONSTRAINT PK_' . $ this -> name . ' PRIMARY KEY (' . $ this -> name . ')' ) ; if ( $ this -> unique ) array_push ( $ query , ",\n\t" . 'CONSTRAINT UC_' . $ this -> name . ' UNIQUE KEY (' . $ this -> name . ')' ) ; if ( $ this -> foreign ) array_push ( $ query , ",\n\tCONSTRAINT FK_$table" . $ this -> foreign_class . '_' . $ this -> name . ' FOREIGN KEY (' . $ this -> name . ") REFERENCES " . $ this -> foreign_class . " (" . $ this -> foreign_property . ')' ) ; return implode ( $ query ) ; } | query statement generation |
42,318 | public static function footer ( ) { $ code = '<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/js/bootstrap-datepicker.min.js"></script>' . chr ( 10 ) ; if ( App :: getLocale ( ) != 'en' ) { $ code .= ' <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/locales/bootstrap-datepicker.' . App :: getLocale ( ) . '.min.js"></script>' . chr ( 10 ) ; } $ code .= ' <script> $(\'input.date-field\').datepicker({ autoclose: true, format: \'' . self :: $ format . '\', language: \'' . App :: getLocale ( ) . '\', todayHighlight: true }); </script>' ; return $ code ; } | Add stuff to the footer . |
42,319 | public function mustBeTypeOf ( string $ type ) : Slot { static $ allowed_types = [ 'boolean' , 'bool' , 'integer' , 'int' , 'float' , 'double' , 'string' , 'array' , 'object' , 'resource' , 'NULL' , 'null' , ] ; $ this -> type = in_array ( $ type , $ allowed_types ) ? $ type : self :: TYPE_ANY ; return $ this ; } | Set type restriction |
42,320 | public function mustBeInstanceOf ( string $ instanceOf ) : Slot { $ this -> instanceOf = class_exists ( $ instanceOf ) || interface_exists ( $ instanceOf ) ? $ instanceOf : self :: INSTANCE_OF_ANY ; return $ this ; } | Set instance - of restriction |
42,321 | public function triggerEvent ( $ name , Event $ event = null ) { return $ this -> e -> trigger ( $ name , $ event ) ; } | Trigger an event on this object . |
42,322 | public function initialize ( ) { if ( ! file_exists ( $ this -> paramsPathname ) ) { throw new \ InvalidArgumentException ( "Invalid Magento root '$this->magentoRoot'." ) ; } $ params = $ this -> getParams ( ) ; $ params [ 'code' ] = $ this -> store ; $ params [ 'type' ] = $ this -> scope ; $ this -> saveParams ( $ params ) ; } | Sets store and scope code into index . php generated by GenericInstaller |
42,323 | public function write ( $ level , $ message , array $ context = array ( ) ) { if ( $ this -> overflowed ) { return ; } $ backtraceLine = '' ; if ( $ this -> logBacktrace ) { $ backtrace = debug_backtrace ( DEBUG_BACKTRACE_PROVIDE_OBJECT , 3 ) ; $ backtrace = array_pop ( $ backtrace ) ; $ backtraceLine = "{$backtrace['file']} : {$backtrace['line']}" ; } if ( in_array ( $ backtraceLine , $ this -> backtraces ) ) { $ backtraceLine = '' ; } else { $ this -> backtraces [ ] = $ backtraceLine ; } $ this -> json [ 'rows' ] [ ] = array ( $ this -> format ( '' , $ message , array ( '__context' => $ context ) ) , $ backtraceLine , $ this -> logLevelMappings [ $ level ] ) ; $ this -> setLastLogLine ( $ message ) ; $ this -> send ( ) ; } | Write logs to the void |
42,324 | protected function send ( ) { if ( ! $ this -> initialized ) { $ this -> initialized = true ; $ this -> sendHeader = $ this -> headersAccepted ( ) ; if ( ! $ this -> sendHeader ) { return ; } } $ jsonEncoded = json_encode ( $ this -> json ) ; $ jsonEncoded = str_replace ( "\n" , '' , $ jsonEncoded ) ; $ encoded = base64_encode ( utf8_encode ( $ jsonEncoded ) ) ; if ( strlen ( $ encoded ) > 240 * 1024 ) { $ this -> overflowed = true ; $ this -> json [ 'rows' ] [ count ( $ this -> json [ 'rows' ] ) - 1 ] = array ( 'Logs truncated, exceeded Chrome header size limit' , '' , '' ) ; $ jsonEncoded = json_encode ( $ this -> json ) ; $ jsonEncoded = str_replace ( "\n" , '' , $ jsonEncoded ) ; $ encoded = base64_encode ( utf8_encode ( $ jsonEncoded ) ) ; } $ this -> sendHeader ( $ encoded ) ; } | Prepare to send header |
42,325 | public static function histogram ( $ values , $ edges ) { $ bins = [ ] ; foreach ( $ edges as $ key => $ val ) { if ( ! isset ( $ edges [ $ key + 1 ] ) ) break ; $ bins [ ] = $ val . '-' . ( $ edges [ $ key + 1 ] ) ; } $ histogram = array_fill_keys ( $ bins , [ ] ) ; foreach ( $ values as $ value ) { $ i = MathHelper :: binary_search ( $ edges , $ value ) ; if ( $ i == - 1 ) { $ message = "Value $value is outside of specified edges array: " . print_r ( $ edges , true ) . "\n" ; throw new \ Exception ( $ message ) ; } $ key = $ bins [ $ i ] ; $ histogram [ $ key ] [ ] = $ value ; } return $ histogram ; } | Creates a histogram with specified bins out of a given array |
42,326 | public function getmodulescounts_forgroups ( $ groupids ) { if ( ! $ db = BFactory :: getDBO ( ) ) { return array ( ) ; } $ qr = 'select count(pageid)as cnt,pageid from soft_modules_rules ' ; $ qr .= ' where pageid in (' . implode ( ',' , $ groupids ) . ')' ; $ qr .= 'group by pageid' ; $ q = $ db -> Query ( $ qr ) ; $ counts = array ( ) ; while ( $ l = $ db -> fetch ( $ q ) ) { $ counts [ $ l [ 'pageid' ] ] = $ l [ 'cnt' ] ; } return $ counts ; } | end of get |
42,327 | public function addDVOConnectorConfig ( $ params ) { return array_merge_recursive ( $ params [ 'config' ] , [ 'postVarSets' => [ '_DEFAULT' => [ 'dvoconnector' => [ [ 'GETvar' => 'tx_dvoconnector_pi1[controller]' , 'noMatch' => 'bypass' , ] , [ 'GETvar' => 'tx_dvoconnector_pi1[aID]' , 'userFunc' => RGU \ Dvoconnector \ Service \ Url \ RealUrlAssociation :: class . '->convert' , ] , [ 'GETvar' => 'tx_dvoconnector_pi1[action]' , 'valueMap' => [ 'veranstaltungen' => 'listEvents' , 'meldungen' => 'listAnnouncements' , 'funktionaere' => 'listFunctionaries' , 'vereinigungen' => 'listAssociations' , 'veranstaltungen-suche' => 'filterEvents' , 'meldungen-suche' => 'filterAnnouncements' , 'funktionaere-suche' => 'filterFunctionaries' , 'vereinigungen-suche' => 'filterAssociations' , 'funktionaer' => 'detailFunctionary' , 'meldung' => 'detailAnnouncement' , 'veranstaltung' => 'detailEvent' , ] , 'noMatch' => 'bypass' , ] , [ 'GETvar' => 'tx_dvoconnector_pi1[@widget_0][currentPage]' , 'noMatch' => 'bypass' , ] , [ 'GETvar' => 'tx_dvoconnector_pi1[eID]' , 'userFunc' => RGU \ Dvoconnector \ Service \ Url \ RealUrlEvent :: class . '->convert' , ] , [ 'GETvar' => 'tx_dvoconnector_pi1[anID]' , 'userFunc' => RGU \ Dvoconnector \ Service \ Url \ RealUrlAnnouncement :: class . '->convert' , ] , [ 'GETvar' => 'tx_dvoconnector_pi1[fID]' , 'userFunc' => RGU \ Dvoconnector \ Service \ Url \ RealUrlFunctionary :: class . '->convert' , ] , [ 'GETvar' => 'tx_dvoconnector_pi1[filter]' , 'userFunc' => RGU \ Dvoconnector \ Service \ Url \ RealUrlFilter :: class . '->convert' , ] , ] ] ] ] ) ; } | Generates additional RealURL configuration and merges it with provided configuration |
42,328 | public function register ( ) { $ this -> container [ 'config' ] -> addLocation ( $ this -> container -> basePath ( ) . '/dev/config' ) ; foreach ( $ this -> container [ 'config' ] -> get ( 'app.providers' ) as $ provider ) { $ this -> container -> addProvider ( $ provider ) ; } } | Register the dev config directory and register providers . |
42,329 | public function hasAcl ( ) { if ( $ this -> acl instanceof Acl \ Acl || static :: $ defaultAcl instanceof Acl \ Acl ) { return true ; } return false ; } | Checks if the helper has an ACL instance |
42,330 | public function hasRole ( ) { if ( $ this -> role instanceof Acl \ Role \ RoleInterface || is_string ( $ this -> role ) || static :: $ defaultRole instanceof Acl \ Role \ RoleInterface || is_string ( static :: $ defaultRole ) ) { return true ; } return false ; } | Checks if the helper has an ACL role |
42,331 | public static function jsonEncode ( $ data ) { $ json = json_encode ( $ data ) ; if ( $ json === false ) { self :: jsonLastError ( ) ; } return $ json ; } | Encode as JSON and throw error if fails |
42,332 | private function updateName ( ) { if ( ! LOCAL ) { $ ds = ldap_connect ( "addressbook.ic.ac.uk" ) ; $ r = ldap_bind ( $ ds ) ; $ justthese = array ( "displayname" ) ; $ sr = ldap_search ( $ ds , "ou=People,ou=shibboleth,dc=ic,dc=ac,dc=uk" , "uid=" . $ this -> getUser ( ) , $ justthese ) ; $ info = ldap_get_entries ( $ ds , $ sr ) ; if ( $ info [ "count" ] > 0 ) { $ this -> setName ( $ info [ 0 ] [ 'displayname' ] [ 0 ] ) ; return ( $ info [ 0 ] [ 'displayname' ] [ 0 ] ) ; } else { return false ; } } else { $ name = $ this -> getName ( ) ; return $ name ; } } | Update user s name from ldap |
42,333 | private function updateEmail ( ) { if ( ! LOCAL ) { $ ds = ldap_connect ( "addressbook.ic.ac.uk" ) ; $ r = ldap_bind ( $ ds ) ; $ justthese = array ( "mail" ) ; $ sr = ldap_search ( $ ds , "ou=People,ou=shibboleth,dc=ic,dc=ac,dc=uk" , "uid=" . $ this -> getUser ( ) , $ justthese ) ; $ info = ldap_get_entries ( $ ds , $ sr ) ; if ( $ info [ "count" ] > 0 ) { $ this -> setEmail ( $ info [ 0 ] [ 'mail' ] [ 0 ] ) ; return ( $ info [ 0 ] [ 'mail' ] [ 0 ] ) ; } else { return false ; } } else { $ email = $ this -> getEmail ( ) ; return $ email ; } } | Update user s email address from ldap |
42,334 | protected function getUiXml ( ) { $ dir = '@data-dir@' . DIRECTORY_SEPARATOR . '@package-name@' . DIRECTORY_SEPARATOR . 'data' ; if ( $ dir [ 0 ] == '@' ) { $ dir = dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data' ; } return $ dir . DIRECTORY_SEPARATOR . 'server-cli.xml' ; } | Gets the XML command line interface definition for this server |
42,335 | public function move ( $ value ) { if ( $ value === $ this -> current ( ) ) { return ; } $ index = $ this -> search ( $ value ) ; if ( false === $ index ) { throw new \ InvalidArgumentException ( sprintf ( '"%s" value not found in JobGraph' , $ value ) ) ; } return $ this -> seek ( $ index ) ; } | Moves cursor to the given value . Useful when using asynchronous transport |
42,336 | public function getJob ( $ index ) { if ( $ this -> hasNextJob ( $ index ) ) { return $ this -> getIterator ( ) -> offsetGet ( $ index ) ; } return false ; } | Get name of the job for given index |
42,337 | public function css ( $ css ) { $ css = trim ( $ css ) ; if ( substr ( $ css , - 1 ) !== ';' ) { $ css = $ css . ';' ; } return $ this -> att ( [ 'style' => $ css ] ) ; } | Add custom style for the icon |
42,338 | function isXmlHttpRequest ( ) { if ( ! $ this -> getMessageObject ( ) -> headers ( ) -> has ( 'X-Requested-With' ) ) return false ; $ header = $ this -> getMessageObject ( ) -> headers ( ) -> get ( 'X-Requested-With' ) ; return false !== $ header && \ Poirot \ Http \ Header \ renderHeader ( $ header ) == 'XMLHttpRequest' ; } | Is the request a Javascript XMLHttpRequest? |
42,339 | function isFlashRequest ( ) { if ( ! $ this -> getMessageObject ( ) -> headers ( ) -> has ( 'User-Agent' ) ) return false ; $ header = $ this -> getMessageObject ( ) -> headers ( ) -> get ( 'User-Agent' ) ; return false !== $ header && stristr ( \ Poirot \ Http \ Header \ renderHeader ( $ header ) , ' flash' ) ; } | Is this a Flash request? |
42,340 | public function modules ( ) { $ courses = $ this -> courses -> pluck ( 'course_id' ) ; return StudyModule :: whereHas ( 'modulesByPeriod.courses' , function ( $ query ) use ( $ courses ) { $ query -> whereIn ( 'course_id' , $ courses ) ; } ) ; } | Get the active study modules for this study . |
42,341 | public function modulesActiveOn ( $ periodId ) { $ courses = $ this -> coursesActiveOn ( $ periodId ) -> pluck ( 'course_id' ) ; return StudyModule :: whereHas ( 'modulesByPeriod.courses' , function ( $ query ) use ( $ courses ) { $ query -> whereIn ( 'course_id' , $ courses ) ; } ) ; } | Get the active study modules for this study on period id . |
42,342 | public function __isset ( $ prop ) { if ( property_exists ( $ this , $ prop ) && $ prop { 0 } != '_' ) { return true ; } $ method = 'get' . ucfirst ( Helper :: denormalize ( $ prop ) ) ; if ( method_exists ( $ this , $ method ) ) { return true ; } if ( method_exists ( $ this , 'callback' ) ) { try { $ this -> callback ( $ method , null ) ; return true ; } catch ( Exception \ UndefinedCallback $ e ) { } } return false ; } | Check if a property is defined but not public or virtual . Note that it will return true if a property _is_ defined but has a value of null . |
42,343 | public static function Eors ( array $ rnpb , $ s ) { $ x ; $ ax ; $ xs ; $ ys ; $ zs ; $ p ; $ q ; $ eo ; $ x = $ rnpb [ 2 ] [ 0 ] ; $ ax = $ x / ( 1.0 + $ rnpb [ 2 ] [ 2 ] ) ; $ xs = 1.0 - $ ax * $ x ; $ ys = - $ ax * $ rnpb [ 2 ] [ 1 ] ; $ zs = - $ x ; $ p = $ rnpb [ 0 ] [ 0 ] * $ xs + $ rnpb [ 0 ] [ 1 ] * $ ys + $ rnpb [ 0 ] [ 2 ] * $ zs ; $ q = $ rnpb [ 1 ] [ 0 ] * $ xs + $ rnpb [ 1 ] [ 1 ] * $ ys + $ rnpb [ 1 ] [ 2 ] * $ zs ; $ eo = ( ( $ p != 0 ) || ( $ q != 0 ) ) ? $ s - atan2 ( $ q , $ p ) : $ s ; return $ eo ; } | - - - - - - - - i a u E o r s - - - - - - - - |
42,344 | public function scriptsAction ( ) { $ locator = $ this -> get ( 'file_locator' ) ; $ content = file_get_contents ( $ locator -> locate ( '@PhlexibleUserBundle/Resources/scripts/ChangePasswordWindow.js' ) ) . file_get_contents ( $ locator -> locate ( '@PhlexibleUserBundle/Resources/scripts/ValidateWindow.js' ) ) . file_get_contents ( $ locator -> locate ( '@PhlexibleUserBundle/Resources/scripts/SetPasswordWindow.js' ) ) ; return new Response ( $ content , 200 , [ 'Content-Type' => 'text/javascript' ] ) ; } | Return user javascripts . |
42,345 | public function translationsAction ( $ language ) { $ language = $ this -> getUser ( ) -> getInterfaceLanguage ( $ language ) ; $ translations = $ this -> get ( 'resourcesTranslations' ) ; $ content = $ translations -> get ( $ language ) ; return new Response ( $ content , 200 , [ 'Content-Type' => 'text/javascript' ] ) ; } | Return users translations . |
42,346 | public function setUri ( $ uri ) { if ( filter_var ( $ uri , FILTER_VALIDATE_URL ) ) { $ this -> uri = $ uri ; } else { throw new RuntimeException ( 'Invalid URI setted.' ) ; } return $ this ; } | Set the URI to perform the request |
42,347 | public function setMethod ( $ method = self :: GET ) { if ( in_array ( $ method , $ this -> allowedMethods ) ) { $ this -> method = $ method ; } else { throw new RuntimeException ( 'Invalid method setted.' ) ; } return $ this ; } | Set the request method to use |
42,348 | public function setHeaders ( $ name , $ value = null ) { if ( is_array ( $ name ) ) { foreach ( $ name as $ k => $ v ) { if ( is_string ( $ k ) ) { $ this -> setHeaders ( $ k , $ v ) ; } else { $ this -> setHeaders ( $ v , null ) ; } } } else { if ( is_null ( $ value ) && ( strpos ( $ name , ':' ) > 0 ) ) { list ( $ name , $ value ) = explode ( ':' , $ name , 2 ) ; } if ( is_null ( $ value ) || $ value === false ) { unset ( $ this -> headers [ $ name ] ) ; } else { if ( is_string ( $ value ) ) { $ value = trim ( $ value ) ; } $ this -> headers [ $ name ] = $ value ; } } return $ this ; } | Set the headers to send in request |
42,349 | public function setParameterGet ( $ name , $ value = null ) { if ( is_array ( $ name ) ) { foreach ( $ name as $ k => $ v ) { $ this -> setParameterGet ( $ k , $ v ) ; } } else { $ parray = & $ this -> paramsGet ; if ( is_null ( $ value ) ) { if ( isset ( $ parray [ $ name ] ) ) unset ( $ parray [ $ name ] ) ; } else { $ parray [ $ name ] = $ value ; } } return $ this ; } | Set a GET parameter for the request |
42,350 | public function setParameterPost ( $ name , $ value = null ) { if ( is_array ( $ name ) ) { foreach ( $ name as $ k => $ v ) { $ this -> setParameterPost ( $ k , $ v ) ; } } else { $ parray = & $ this -> paramsPost ; if ( is_null ( $ value ) ) { if ( isset ( $ parray [ $ name ] ) ) unset ( $ parray [ $ name ] ) ; } else { $ parray [ $ name ] = $ value ; } } return $ this ; } | Set a POST parameter for the request |
42,351 | public function rawData ( $ bool = false ) { if ( is_bool ( $ bool ) ) { $ this -> useRawData = $ bool ; } else { throw new RuntimeException ( 'Invalid parameter type, expected boolean, got ' . gettype ( $ bool ) ) ; } return $ this ; } | Set true or false to use RAW data in request |
42,352 | public function setRawData ( $ data ) { if ( is_string ( $ data ) ) { $ this -> rawData ( true ) ; $ this -> dataRaw = $ data ; } else { throw new RuntimeException ( 'Invalid RAW data setted.' ) ; } return $ this ; } | Set the RAW data for the request |
42,353 | public function setFiles ( $ file , $ name = null ) { if ( is_array ( $ file ) ) { foreach ( $ file as $ k => $ v ) { $ this -> setFiles ( $ v , $ k ) ; } } else { $ parray = & $ this -> files ; if ( file_exists ( $ file ) ) { if ( is_null ( $ file ) ) { if ( isset ( $ parray [ $ name ] ) ) unset ( $ parray [ $ name ] ) ; } else { if ( is_null ( $ name ) || is_integer ( $ name ) ) { $ count = count ( $ parray ) ; $ name = 'file_contents_' . $ count ; } $ parray [ $ name ] = $ file ; } } else { throw new RuntimeException ( 'Invalid file, file not exists.' ) ; } } return $ this ; } | Set files for send in request |
42,354 | public function setHTTPVersion ( $ version = self :: HTTP_1 ) { if ( $ version == self :: HTTP_0 || $ version == self :: HTTP_1 ) { $ this -> httpVersion = $ version ; } else { throw new RuntimeException ( 'Invalid HTTP version setted.' ) ; } return $ this ; } | Set HTTP protocol version for request |
42,355 | public function setCurlOpts ( $ opt , $ value = null ) { if ( is_array ( $ opt ) ) { foreach ( $ opt as $ k => $ v ) { $ this -> setCurlOpts ( $ k , $ v ) ; } } else { $ this -> curlOpts [ $ opt ] = $ value ; } return $ this ; } | Set custom CURL options for CURL handle |
42,356 | public function noReset ( $ bool = false ) { if ( is_bool ( $ bool ) ) { $ this -> noReset = $ bool ; } else { throw new RuntimeException ( 'Invalid parameter type setted, expected boolean, got ' . gettype ( $ bool ) ) ; } } | Set true or false for reset the Client state after request |
42,357 | public function reset ( ) { $ this -> uri = null ; $ this -> method = self :: GET ; $ this -> headers = array ( ) ; $ this -> paramsGet = array ( ) ; $ this -> paramsPost = array ( ) ; $ this -> useRawData = false ; $ this -> dataRaw = null ; $ this -> httpVersion = self :: HTTP_1 ; $ this -> curlOpts = array ( ) ; return $ this ; } | Reset the Client state |
42,358 | public function loadClassMetadata ( LoadClassMetadataEventArgs $ eventArgs ) { $ classMetadata = $ eventArgs -> getClassMetadata ( ) ; if ( null === $ classMetadata -> getReflectionClass ( ) || false == $ this -> isModular ( $ classMetadata ) || 'Harmony\Component\ModularRouting\StaticModule' == $ this -> getModuleClass ( ) || $ classMetadata -> hasField ( 'module' ) || $ classMetadata -> hasAssociation ( 'module' ) ) { return ; } $ classMetadata -> mapManyToOne ( [ 'targetEntity' => $ this -> getModuleClass ( ) , 'fieldName' => 'module' , 'joinColumns' => [ [ 'name' => 'module_id' , 'referencedColumnName' => 'id' , ] , ] , ] ) ; } | Handles actions when metadata is loaded . |
42,359 | public function prePersist ( LifecycleEventArgs $ args ) { $ entity = $ args -> getEntity ( ) ; $ entityManager = $ args -> getEntityManager ( ) ; $ classMetadata = $ entityManager -> getClassMetadata ( get_class ( $ entity ) ) ; if ( false == $ this -> isModular ( $ classMetadata ) ) { return ; } if ( null === $ entity -> getModule ( ) && null !== $ this -> getModuleManager ( ) -> getCurrentModule ( ) ) { $ entity -> setModule ( $ this -> getModuleManager ( ) -> getCurrentModule ( ) ) ; } } | Handles actions before creation of an entity . |
42,360 | public function get ( $ name , array $ parameters = [ ] ) { if ( isset ( $ this -> shared [ $ name ] ) ) { return $ this -> shared [ $ name ] ; } if ( ! $ this -> has ( $ name ) ) { throw new NotFoundException ( 'No definition found for service "' . $ name . '".' ) ; } $ definition = $ this -> definitions [ $ name ] ; if ( isset ( $ definition [ 'alias' ] ) ) { return $ this -> get ( $ definition [ 'alias' ] ) ; } if ( isset ( $ definition [ 'init' ] ) ) { $ service_class = call_user_func ( $ definition [ 'init' ] , $ this , $ parameters ) ; if ( $ service_class === false ) { throw new NotFoundException ( '"Init" directive for service "' . $ name . '" did not produced any object.' ) ; } } else { $ arguments = [ ] ; if ( isset ( $ definition [ 'arguments' ] ) ) { $ arguments = $ this -> resolveArrayOfArguments ( $ definition [ 'arguments' ] , $ parameters ) ; } if ( isset ( $ definition [ 'static' ] ) ) { $ service_class = call_user_func_array ( [ $ definition [ 'class' ] , $ definition [ 'static' ] ] , $ arguments ) ; if ( $ service_class === false ) { throw new NotFoundException ( 'Class "' . $ definition [ 'class' ] . '" for service "' . $ name . '" was not found.' ) ; } } else { try { $ reflection_class = new \ ReflectionClass ( $ definition [ 'class' ] ) ; } catch ( \ ReflectionException $ e ) { throw new NotFoundException ( 'Class "' . $ definition [ 'class' ] . '" for service "' . $ name . '" was not found.' ) ; } $ service_class = $ reflection_class -> newInstanceArgs ( $ arguments ) ; } } if ( isset ( $ definition [ 'after' ] ) ) { call_user_func ( $ definition [ 'after' ] , $ this , $ service_class , $ parameters ) ; } if ( isset ( $ definition [ 'shared' ] ) && $ definition [ 'shared' ] === true ) { $ this -> shared [ $ name ] = $ service_class ; } return $ service_class ; } | get Get service instance . |
42,361 | public function calculate ( $ values ) { $ dataToReplace = array ( ) ; foreach ( $ this -> getVariables ( ) as $ mask => $ var ) { $ var = $ values [ $ var ] ; if ( $ var instanceof \ DateTime ) { $ var = new \ Zend_Date ( $ var -> getTimestamp ( ) ) ; $ var = $ var -> get ( self :: DEFAULT_DATETIME_MASK ) ; } $ dataToReplace [ $ mask ] = $ var ; } $ condition = str_replace ( array_keys ( $ dataToReplace ) , array_values ( $ dataToReplace ) , $ this -> condition ) ; $ condition = explode ( $ this -> operator , $ condition ) ; if ( is_numeric ( $ condition [ 0 ] ) ) { $ condition [ 0 ] = floatval ( $ condition [ 0 ] ) ; } else { $ condition [ 0 ] = trim ( $ condition [ 0 ] ) ; } if ( is_numeric ( $ condition [ 1 ] ) ) { $ condition [ 1 ] = floatval ( $ condition [ 1 ] ) ; } else { $ condition [ 1 ] = trim ( $ condition [ 1 ] ) ; } $ out = null ; switch ( $ this -> operator ) { case self :: OPERATOR_EQ : $ out = $ condition [ 0 ] == $ condition [ 1 ] ; break ; case self :: OPERATOR_NEQ : $ out = $ condition [ 0 ] != $ condition [ 1 ] ; break ; case self :: OPERATOR_GRATER : $ out = $ condition [ 0 ] > $ condition [ 1 ] ; break ; case self :: OPERATOR_GRATER_EQ : $ out = $ condition [ 0 ] >= $ condition [ 1 ] ; break ; case self :: OPERATOR_LESS : $ out = $ condition [ 0 ] < $ condition [ 1 ] ; break ; case self :: OPERATOR_LESS_EQ : $ out = $ condition [ 0 ] <= $ condition [ 1 ] ; break ; default : throw new Exception \ UnknownPairOperatorException ( 'Operator "' . $ this -> operator . '" is not supported.' ) ; } return $ out ; } | Calculating condition by given values . |
42,362 | public function getProperty ( $ rel = null ) { if ( $ rel == null ) { return $ this -> _property ; } else { foreach ( $ this -> _property as $ p ) { if ( $ p -> rel == $ rel ) { return $ p ; } } return null ; } } | Returns all property tags for this entry |
42,363 | protected function processTasks ( $ tasks ) { foreach ( $ tasks as $ taskName => $ taskConfig ) { $ serviceId = sprintf ( 'task.%s' , $ taskName ) ; $ this -> container -> setDefinition ( $ serviceId , new Definition ( ) ) -> setSynthetic ( true ) ; $ command = $ this -> buildTask ( $ taskName , $ taskConfig ) ; $ this -> container -> set ( $ serviceId , $ command ) ; $ this -> container -> get ( 'application' ) -> add ( $ command ) ; } } | Process tasks that the user has defined and turn them into commands that can be ran . |
42,364 | public function perform ( AgentInterface $ agent , GridMetadata $ gridMetadata , string $ actionName , array $ selectedIdentifiers ) : ActionResponseInterface { $ actionMetadatas = $ gridMetadata -> getActions ( ) ; if ( ! isset ( $ actionMetadatas [ $ actionName ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Action "%s" is not available for class "%s". Availabile actions: "%s"' , $ actionName , $ gridMetadata -> getClassMetadata ( ) -> name , implode ( '", "' , array_keys ( $ actionMetadatas ) ) ) ) ; } $ actionMetadata = $ actionMetadatas [ $ actionName ] ; $ action = $ this -> registry -> get ( $ actionMetadata -> getType ( ) ) ; $ options = new OptionsResolver ( ) ; $ action -> configureOptions ( $ options ) ; $ options = $ options -> resolve ( $ actionMetadata -> getOptions ( ) ) ; return $ action -> perform ( $ agent , $ gridMetadata -> getClassMetadata ( ) -> name , $ selectedIdentifiers , $ options ) ; } | Retrieve a collection from the given agent using the given metadata and identifiers and perform the named action on each member of the collection . |
42,365 | public static function Rx ( $ phi , array & $ r ) { $ s ; $ c ; $ a10 ; $ a11 ; $ a12 ; $ a20 ; $ a21 ; $ a22 ; $ s = sin ( $ phi ) ; $ c = cos ( $ phi ) ; $ a10 = $ c * $ r [ 1 ] [ 0 ] + $ s * $ r [ 2 ] [ 0 ] ; $ a11 = $ c * $ r [ 1 ] [ 1 ] + $ s * $ r [ 2 ] [ 1 ] ; $ a12 = $ c * $ r [ 1 ] [ 2 ] + $ s * $ r [ 2 ] [ 2 ] ; $ a20 = - $ s * $ r [ 1 ] [ 0 ] + $ c * $ r [ 2 ] [ 0 ] ; $ a21 = - $ s * $ r [ 1 ] [ 1 ] + $ c * $ r [ 2 ] [ 1 ] ; $ a22 = - $ s * $ r [ 1 ] [ 2 ] + $ c * $ r [ 2 ] [ 2 ] ; $ r [ 1 ] [ 0 ] = $ a10 ; $ r [ 1 ] [ 1 ] = $ a11 ; $ r [ 1 ] [ 2 ] = $ a12 ; $ r [ 2 ] [ 0 ] = $ a20 ; $ r [ 2 ] [ 1 ] = $ a21 ; $ r [ 2 ] [ 2 ] = $ a22 ; return ; } | - - - - - - i a u R x - - - - - - |
42,366 | private function getIndex ( $ key , $ tags ) { $ tagFolder = $ this -> createFolderNameFromTags ( $ tags ) ; if ( ! is_dir ( $ tagFolder ) ) { mkdir ( $ tagFolder , 0755 , true ) ; } $ folder = $ tagFolder . substr ( $ key , 0 , 2 ) . DIRECTORY_SEPARATOR . substr ( $ key , 2 , 2 ) . DIRECTORY_SEPARATOR . substr ( $ key , 4 , 2 ) . DIRECTORY_SEPARATOR ; if ( ! is_dir ( $ folder ) ) { mkdir ( $ folder , 0755 , true ) ; } return $ folder . 'index.db' ; } | Based on the provided key and tag list a path to the index is created and returned . |
42,367 | private function createFolderNameFromTags ( array $ tags ) { natsort ( $ tags ) ; $ tagFolder = '_' ; foreach ( $ tags as $ t ) { $ tagFolder .= $ t . '_' ; } return $ this -> indexDir . $ tagFolder . DIRECTORY_SEPARATOR ; } | Based on the provided list of tags a path to the root tags folder is created . |
42,368 | public function getErrorMessage ( ) : string { static $ messages = [ UPLOAD_ERR_OK => 'Upload successful' , UPLOAD_ERR_INI_SIZE => 'The size of the file exceeds the value of the "upload_max_filesize" directive in php.ini' , UPLOAD_ERR_FORM_SIZE => 'The size of the file exceeds the value of the "MAX_FILE_SIZE" input in the HTML form' , UPLOAD_ERR_PARTIAL => 'The file was only partially uploaded' , UPLOAD_ERR_NO_FILE => 'No file was uploaded' , UPLOAD_ERR_NO_TMP_DIR => 'Temporary directory is missing' , UPLOAD_ERR_CANT_WRITE => 'Failed to write the file to disk' , UPLOAD_ERR_EXTENSION => 'A PHP extension stopped the file upload' , ] ; return $ messages [ $ this -> statusCode ] ; } | Get a human - readable error message of the upload status . Do not use this to check the upload status! |
42,369 | public function moveTo ( string $ destination ) { if ( ! $ this -> isValid ( ) ) { throw new FileMoveException ( 'File was not uploaded successfully and thus cannot be moved' ) ; } if ( $ this -> hasBeenMoved ) { throw new FileMoveException ( 'Uploaded file has already been moved' ) ; } if ( is_dir ( $ destination ) ) { $ directory = $ destination ; $ filename = $ this -> name ; } else { $ directory = dirname ( $ destination ) ; $ filename = basename ( $ destination ) ; } if ( ! is_dir ( $ directory ) ) { throw new FileMoveException ( $ destination . ' - folder does not exist' ) ; } if ( ! is_writable ( $ directory ) ) { throw new FileMoveException ( $ destination . ' - folder is not writable, check permissions' ) ; } if ( ! move_uploaded_file ( $ this -> path , $ directory . DIRECTORY_SEPARATOR . $ filename ) ) { throw new FileMoveException ( 'Failed to move uploaded file to ' . $ destination ) ; } $ this -> hasBeenMoved = true ; return $ directory . DIRECTORY_SEPARATOR . $ filename ; } | Move the newly uploaded file to another directory and optionally rename it . This method can only be called once subsequent calls will throw an exception . |
42,370 | public function getBought ( ) { $ items = Item :: join ( 'seller' ) -> leftJoin ( 'purchases' ) -> where ( 'purchases.user_id' , Auth :: user ( ) -> userId ) ; if ( mustard_loaded ( 'auctions' ) ) { $ items -> leftJoin ( 'winningBid' ) -> orWhere ( 'bids.user_id' , Auth :: user ( ) -> userId ) ; } $ table = new InventoryBought ( $ items ) ; return view ( 'mustard::inventory.bought' , [ 'table' => $ table , 'items' => $ table -> paginate ( ) , ] ) ; } | Return the inventory bought items view . |
42,371 | public function getSold ( ) { $ items = Auth :: user ( ) -> items ( ) -> leftJoin ( 'purchases' ) -> where ( function ( $ query ) { $ query -> typeFixed ( ) -> whereNotNull ( 'purchases.purchase_id' ) ; } ) ; $ items -> getBaseQuery ( ) -> join ( 'users' , 'users.user_id' , '=' , 'purchases.user_id' ) ; if ( mustard_loaded ( 'auctions' ) ) { $ items -> leftJoin ( 'winningBid' ) -> orWhere ( function ( $ query ) { $ query -> typeAuction ( ) -> whereNotNull ( 'bids.bid_id' ) ; } ) ; } $ table = new InventorySold ( $ items ) ; return view ( 'mustard::inventory.sold' , [ 'table' => $ table , 'items' => $ table -> paginate ( ) , ] ) ; } | Return the inventory sold items view . |
42,372 | public function getUnsold ( ) { $ items = Auth :: user ( ) -> items ( ) -> with ( 'purchases' ) -> where ( function ( $ query ) { $ query -> has ( 'purchases' , 0 ) -> where ( 'end_date' , '<' , time ( ) ) -> where ( 'auction' , false ) -> orWhere ( function ( $ query ) { $ query -> where ( 'auction' , true ) -> where ( 'end_date' , '<' , time ( ) ) -> where ( 'winning_bid_id' , 0 ) ; } ) ; } ) ; $ table = new InventoryUnsold ( $ items ) ; return view ( 'mustard::inventory.unsold' , [ 'table' => $ table , 'items' => $ table -> paginate ( ) , ] ) ; } | Return the inventory unsold items view . |
42,373 | public function createService ( ServiceLocatorInterface $ services ) { $ manager = $ services -> get ( 'Zend\Session\ManagerInterface' ) ; $ storage = new Session ( null , null , $ manager ) ; return new AuthenticationService ( $ services , $ storage ) ; } | Create authentication service |
42,374 | public function addMiddleware ( Middleware $ middleware ) { $ group = $ middleware -> getGroup ( ) ; if ( ! isset ( $ this -> middleware [ $ group ] ) ) { $ this -> middleware [ $ group ] = array ( 'before' => array ( ) , 'after' => array ( ) ) ; } $ this -> middleware [ $ group ] [ $ middleware -> getPosition ( ) ] [ ] = & $ middleware ; } | Add middleware trigger to registry . |
42,375 | private function executeRoute ( Route & $ route , $ method , $ force = false ) { $ continue = true ; if ( ! $ force ) { $ continue = $ this -> executeRouteMiddleware ( $ route , 'before' , $ method ) ; } if ( $ continue === true ) { $ route -> execute ( $ this -> compiled ) ; } if ( ! $ force ) { $ this -> executeRouteMiddleware ( $ route , 'after' , $ method ) ; } } | Will try to match parameters and execute the callback . Will also trigger middleware . |
42,376 | private function executeRouteMiddleware ( Route & $ route , $ position , $ method ) { $ method = strtoupper ( $ method ) ; $ middleware = array ( ) ; $ continue = true ; if ( isset ( $ this -> middleware [ 'global' ] , $ this -> middleware [ 'global' ] [ $ position ] ) && count ( $ this -> middleware [ 'global' ] [ $ position ] ) > 0 ) { $ middleware = array_merge ( $ middleware , $ this -> middleware [ 'global' ] [ $ position ] ) ; } if ( $ route -> getGroup ( ) !== null && isset ( $ this -> middleware [ $ route -> getGroup ( ) ] , $ this -> middleware [ $ route -> getGroup ( ) ] [ $ position ] ) && count ( $ this -> middleware [ $ route -> getGroup ( ) ] [ $ position ] ) > 0 ) { $ middleware = array_merge ( $ middleware , $ this -> middleware [ $ route -> getGroup ( ) ] [ $ position ] ) ; } foreach ( $ middleware as $ trigger ) { if ( count ( $ trigger -> getMethods ( ) ) === 0 || in_array ( strtoupper ( $ method ) , $ trigger -> getMethods ( ) ) ) { if ( $ this -> executeMiddleware ( $ trigger ) === false ) { $ continue = false ; } } } return $ continue ; } | Execute middleware found for the route . |
42,377 | public function subject ( $ subject ) { $ name = Config :: get ( 'name' ) ; $ subject = '[' . $ name . '] ' . $ subject ; $ subject = '=?utf-8?B?' . base64_encode ( $ subject ) . '?=' ; $ this -> message -> setSubject ( $ subject ) ; return $ this ; } | set message subject |
42,378 | public function body ( $ body , $ contentType = null ) { $ this -> message -> setBody ( $ body , $ contentType ) ; return $ this ; } | set message body |
42,379 | public function view ( $ template , $ data = [ ] ) { $ html = ViewService :: getEngine ( ) -> render ( $ template , $ data ) ; $ this -> message -> setBody ( $ html , 'text/html' ) ; return $ this ; } | set message body with twig template |
42,380 | public function median ( $ key = null ) { $ count = $ this -> count ( ) ; if ( $ count == 0 ) { return ; } $ values = $ this -> with ( isset ( $ key ) ? $ this -> pluck ( $ key ) : $ this ) -> sort ( ) -> values ( ) ; $ middle = ( int ) ( $ count / 2 ) ; if ( $ count % 2 ) { return $ values -> get ( $ middle ) ; } return ( new static ( [ $ values -> get ( $ middle - 1 ) , $ values -> get ( $ middle ) ] ) ) -> average ( ) ; } | Get the median of a given key . |
42,381 | public function containsStrict ( $ key , $ value = null ) { if ( func_num_args ( ) == 2 ) { return $ this -> contains ( function ( $ item ) use ( $ key , $ value ) { return ArrayHelper :: dataGet ( $ item , $ key ) === $ value ; } ) ; } if ( $ this -> useAsCallable ( $ key ) ) { return ! is_null ( $ this -> first ( $ key ) ) ; } return in_array ( $ key , $ this -> items , true ) ; } | Determine if an item exists in the collection using strict comparison . |
42,382 | protected final function doRequest ( ) { $ stepId = count ( $ this -> results ) ; $ request = $ this -> steps [ $ stepId ] ( $ this -> results ) ; $ response = $ this -> requestor -> doRequest ( $ request ) ; $ this -> checkGotResponse ( $ response ) ; $ this -> saveResult ( $ stepId , $ response ) ; } | Request and store the choices for the current step . |
42,383 | public function pushTweet ( $ tweet ) { if ( $ this -> maxPushesPerHour > 0 && $ this -> cache ) { $ hourAgo = new \ DateTime ( '- 1 hour' ) ; $ tweetTimes = $ this -> cache -> fetch ( static :: CACHE_KEY ) ? : [ ] ; foreach ( $ tweetTimes as $ k => $ time ) { if ( $ time < $ hourAgo ) { unset ( $ tweetTimes [ $ k ] ) ; } } if ( ( $ count = count ( $ tweetTimes ) ) >= $ this -> maxPushesPerHour ) { throw new MaxPushesPerHourException ( "Cannot send push, $count have already been sent. The limit is {$this->maxPushesPerHour}" ) ; } $ tweetTimes [ ] = new \ DateTime ( ) ; $ this -> cache -> save ( static :: CACHE_KEY , $ tweetTimes , 3600 ) ; } $ m = $ this -> getMessageForTweet ( $ tweet ) ; if ( $ this -> topicArn ) { $ this -> messages -> send ( $ m , $ this -> topicArn ) ; } else { $ this -> messages -> broadcast ( $ m ) ; } } | Send a tweet to everyone |
42,384 | public function printDocument ( ) { header ( "Content-Type: {$this->_contentType}; {$this->_charset}" ) ; try { $ this -> controller -> processRequest ( ) ; } catch ( Exception $ e ) { $ message = substr ( preg_replace ( '/\s+/' , ' ' , $ e -> getMessage ( ) ) , 0 , 150 ) ; header ( "HTTP/1.0 400 $message" ) ; throw $ e ; } echo $ this -> getDocument ( ) ; } | Prints the document . |
42,385 | public function getConfig ( $ name ) { return isset ( $ this -> settings [ $ name ] ) ? $ this -> settings [ $ name ] : null ; } | Read and Write config |
42,386 | public function cacheVal ( $ value , $ id = null ) { if ( $ id == null ) { if ( is_object ( $ value ) ) $ id = $ this -> getIDfromOjb ( $ value ) ; if ( $ id == null && $ this -> getConfig ( 'debug' ) ) { echo "no caching key" ; return $ value ; } } $ cachefile = $ this -> getConfig ( 'cacheDir' ) . '/' . utf8_decode ( $ id ) ; $ cachetime = $ this -> getConfig ( 'cacheTime' ) ; if ( file_exists ( $ cachefile ) && time ( ) - $ cachetime < fileatime ( $ cachefile ) ) { $ ser = file_get_contents ( $ cachefile ) ; $ val = bzdecompress ( unserialize ( $ ser ) ) ; return $ val ; } else { $ ser = bzcompress ( serialize ( $ value ) ) ; file_put_contents ( $ cachefile , $ ser ) ; return $ value ; } if ( $ this -> getConfig ( 'debug' ) ) echo "no caching" ; } | get cached value in time or return value |
42,387 | public function cacheFun ( $ function ) { if ( $ this -> getConfig ( 'debug' ) && ! is_callable ( $ function ) ) echo "no valid function" ; $ r = new ReflectionFunction ( $ function ) ; $ id = null ; foreach ( $ r -> getStaticVariables ( ) as $ key => $ var ) { if ( $ key == 'key' ) $ id = $ var ; } if ( is_object ( $ id ) ) $ id = $ this -> getIDfromOjb ( $ id ) ; if ( $ id == null && $ this -> getConfig ( 'debug' ) ) { echo "no caching key" ; return $ function ( ) ; } $ cachefile = $ this -> getConfig ( 'cacheDir' ) . '/' . utf8_decode ( $ id ) ; $ cachetime = $ this -> getConfig ( 'cacheTime' ) ; if ( file_exists ( $ cachefile ) && time ( ) - $ cachetime < fileatime ( $ cachefile ) ) { $ ser = file_get_contents ( $ cachefile ) ; $ val = bzdecompress ( unserialize ( $ ser ) ) ; return $ val ; } else { $ value = $ function ( ) ; $ ser = serialize ( bzcompress ( $ value ) ) ; file_put_contents ( $ cachefile , $ ser ) ; return $ value ; } if ( $ this -> getConfig ( 'debug' ) ) echo "no caching" ; } | cache function result and return it |
42,388 | public function isCached ( $ id ) { if ( $ id != null ) { $ id = $ this -> getIDfromOjb ( $ id ) ; } if ( $ id == null ) return false ; $ cachefile = $ this -> getConfig ( 'cacheDir' ) . '/' . utf8_decode ( $ id ) ; $ cachetime = $ this -> getConfig ( 'cacheTime' ) ; if ( file_exists ( $ cachefile ) && time ( ) - $ cachetime < fileatime ( $ cachefile ) ) { return true ; } return false ; } | check if key or object in first parameter is cached . Returns true if cached |
42,389 | public function clearCache ( ) { $ files = glob ( $ this -> getConfig ( 'cacheDir' ) . '/*' , GLOB_MARK ) ; foreach ( $ files as $ file ) { unlink ( $ file ) ; } } | delete all cached files |
42,390 | public function gc ( ) { $ files = glob ( $ this -> getConfig ( 'cacheDir' ) . '/*' , GLOB_MARK ) ; $ cachetime = $ this -> getConfig ( 'cacheTime' ) ; foreach ( $ files as $ file ) { if ( time ( ) - $ cachetime > fileatime ( $ file ) ) unlink ( $ file ) ; } } | delete old cached files |
42,391 | function parseString ( $ html ) { $ this -> parser -> html = $ html ; $ this -> parse ( ) ; return $ this -> output ; } | parse a HTML string |
42,392 | function flushStacked ( ) { foreach ( $ this -> stack as $ tag => $ a ) { if ( ! empty ( $ a ) ) { call_user_func ( array ( & $ this , 'flushStacked_' . $ tag ) ) ; } } } | output all stacked tags |
42,393 | function flushLinebreaks ( ) { if ( $ this -> lineBreaks && ! empty ( $ this -> output ) ) { $ this -> out ( str_repeat ( "\n" . $ this -> indent , $ this -> lineBreaks ) , true ) ; } $ this -> lineBreaks = 0 ; } | flush enqued linebreaks |
42,394 | function handleText ( ) { if ( $ this -> hasParent ( 'pre' ) && strpos ( $ this -> parser -> node , "\n" ) !== false ) { $ this -> parser -> node = str_replace ( "\n" , "\n" . $ this -> indent , $ this -> parser -> node ) ; } if ( ! $ this -> hasParent ( 'code' ) && ! $ this -> hasParent ( 'pre' ) ) { $ this -> parser -> node = $ this -> decode ( $ this -> parser -> node ) ; if ( ! $ this -> skipConversion ) { $ this -> parser -> node = preg_replace ( $ this -> escapeInText [ 'search' ] , $ this -> escapeInText [ 'replace' ] , $ this -> parser -> node ) ; } } else { $ this -> parser -> node = str_replace ( array ( '"' , '&apos' ) , array ( '"' , '\'' ) , $ this -> parser -> node ) ; } $ this -> out ( $ this -> parser -> node ) ; $ this -> lastClosedTag = '' ; } | handle plain text |
42,395 | function stack ( ) { if ( ! isset ( $ this -> stack [ $ this -> parser -> tagName ] ) ) { $ this -> stack [ $ this -> parser -> tagName ] = array ( ) ; } array_push ( $ this -> stack [ $ this -> parser -> tagName ] , $ this -> parser -> tagAttributes ) ; } | add current node to the stack this only stores the attributes |
42,396 | function unstack ( ) { if ( ! isset ( $ this -> stack [ $ this -> parser -> tagName ] ) || ! is_array ( $ this -> stack [ $ this -> parser -> tagName ] ) ) { trigger_error ( 'Trying to unstack from empty stack. This must not happen.' , E_USER_ERROR ) ; } return array_pop ( $ this -> stack [ $ this -> parser -> tagName ] ) ; } | remove current tag from stack |
42,397 | function decode ( $ text , $ quote_style = ENT_QUOTES ) { if ( version_compare ( PHP_VERSION , '5' , '>=' ) ) { $ text = html_entity_decode ( $ text , $ quote_style , 'UTF-8' ) ; } else { if ( function_exists ( 'html_entity_decode' ) ) { $ text = html_entity_decode ( $ text , $ quote_style , 'ISO-8859-1' ) ; } else { static $ trans_tbl ; if ( ! isset ( $ trans_tbl ) ) { $ trans_tbl = array_flip ( get_html_translation_table ( HTML_ENTITIES , $ quote_style ) ) ; } $ text = strtr ( $ text , $ trans_tbl ) ; } $ text = preg_replace_callback ( '~&#x([0-9a-f]+);~i' , array ( & $ this , '_decode_hex' ) , $ text ) ; $ text = preg_replace_callback ( '~&#(\d{2,5});~' , array ( & $ this , '_decode_numeric' ) , $ text ) ; } return $ text ; } | decode email addresses |
42,398 | private function createCreateForm ( MediaType $ entity ) { $ form = $ this -> createForm ( new MediaTypeType ( ) , $ entity , array ( 'action' => $ this -> generateUrl ( 'mediatype_create' ) , 'method' => 'POST' , ) ) ; $ form -> add ( 'submit' , 'submit' , array ( 'label' => 'Create' ) ) ; return $ form ; } | Creates a form to create a MediaType entity . |
42,399 | public function newAction ( ) { $ entity = new MediaType ( ) ; $ form = $ this -> createCreateForm ( $ entity ) ; return array ( 'entity' => $ entity , 'form' => $ form -> createView ( ) , ) ; } | Displays a form to create a new MediaType entity . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.