idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
24,300
public function field_name ( $ num ) { $ info = $ this -> field_info_by_num ( $ num ) ; if ( ! $ info ) { return null ; } return \ SmartFactory \ checkempty ( $ info [ "name" ] ) ; }
Returns the name of the field by number .
24,301
private function resolvePath ( $ key , $ createDir = true ) : string { $ hash = self :: createKeyHash ( $ key ) ; $ path = $ this -> cachePath . $ this -> cacheName . '/' ; for ( $ i = 0 ; $ i < self :: CACHE_LEVEL ; $ i ++ ) { $ path .= substr ( $ hash , 2 * ( $ i ) , 2 ) . '/' ; if ( $ createDir && ! is_dir ( $ path ) ) { mkdir ( $ path ) ; } } return $ path . $ hash ; }
Resolves the path for a cache key .
24,302
public function get ( $ cacheKey ) { $ path = $ this -> resolvePath ( $ cacheKey , false ) ; if ( file_exists ( $ path ) ) { return file_get_contents ( $ path ) ; } return null ; }
Gets a value from the cache .
24,303
public function isCached ( $ cacheKey ) { $ path = $ this -> resolvePath ( $ cacheKey , false ) ; if ( file_exists ( $ path ) ) { return $ path ; } else { return false ; } }
checks if a value is cached for a cache key .
24,304
public function setObject ( ICacheable $ cacheable ) { if ( ! $ this -> isDisabled ( ) ) { $ path = $ this -> resolvePath ( $ cacheable -> getCacheKey ( ) , true ) ; file_put_contents ( $ path , $ cacheable -> getCacheValue ( ) ) ; } }
puts a cacheable object into the cache .
24,305
public function setString ( $ key , $ value ) { if ( ! $ this -> isDisabled ( ) ) { $ path = $ this -> resolvePath ( $ key , true ) ; file_put_contents ( $ path , $ value ) ; } }
puts a string into the cache .
24,306
public function createView ( $ object ) { $ view = $ this -> viewFactory -> createView ( $ object ) ; if ( $ view instanceof View ) { $ this -> extend ( $ view , $ object ) ; } return $ view ; }
Create a view for the object .
24,307
public function clear ( ) { $ finder = new Finder ( ) ; foreach ( $ finder -> files ( ) -> in ( $ this -> cacheDir ) -> depth ( 0 ) -> name ( self :: CACHE_PATH_REGEX ) as $ file ) { @ unlink ( $ file -> getRealPath ( ) ) ; } }
The routing cache needs to be cleared after a change . This is faster then clearing the cache with the responsible command .
24,308
protected function loadAuthorizeObject ( $ id , $ action ) { $ model = $ this -> getRepository ( ) -> findById ( $ id , [ ] , app ( 'context' ) ) ; if ( empty ( $ model ) ) { throw new NotFoundHttpException ( "Object ($id) not found" ) ; } if ( ! $ model -> isAllowed ( $ action ) ) { throw new AccessDeniedHttpException ( "Forbidden" ) ; } return $ model ; }
Get the object and check to make sure the authorized user has access
24,309
protected function getFractalItem ( $ model ) { $ transformer = $ this -> getTransformer ( ) ; $ item = new FractalItem ( $ model , $ transformer , $ this -> getResourceKey ( ) ) ; $ item -> setMeta ( $ transformer -> getMeta ( $ model ) ) ; return $ item ; }
Get the fractal item object
24,310
public function setOptions ( $ options ) { $ format = null ; if ( isset ( $ options [ 'date_format' ] ) ) { $ format = $ options [ 'date_format' ] ; unset ( $ options [ 'date_format' ] ) ; } elseif ( isset ( $ options [ 'format' ] ) ) { $ format = $ options [ 'format' ] ; unset ( $ options [ 'format' ] ) ; } if ( $ format ) { $ options [ 'format' ] = $ format ; } parent :: setOptions ( $ options ) ; return $ this ; }
Allow the format key to be format and date_format For consistency with the ZF2 Date Element .
24,311
public static function Anp ( $ a ) { $ w ; $ w = fmod ( $ a , D2PI ) ; if ( $ w < 0 ) $ w += D2PI ; return $ w ; }
- - - - - - - i a u A n p - - - - - - -
24,312
public function registerEvent ( $ event , $ object , $ fn ) { $ this -> actions [ $ event ] [ ] = new \ OWeb \ manage \ events \ Event ( $ object , $ fn ) ; }
Register a function to be called in a certain event .
24,313
public function sendEvent ( $ event , $ params = array ( ) ) { if ( isset ( $ this -> actions [ $ event ] ) ) { foreach ( $ this -> actions [ $ event ] as $ eventO ) { $ eventO -> doEvent ( $ params ) ; } } }
Will send and event and call the functions that has registered to that Event .
24,314
public static function getTransformedFilesize ( $ size = 0 , $ round = 3 , $ dec_delimiter = ',' ) { $ count = 0 ; while ( $ size >= 1024 && $ count < ( count ( self :: $ FILESIZE_ORDERED_UNITS ) - 1 ) ) { $ count ++ ; $ size /= 1024 ; } if ( $ round >= 0 ) { $ arr = pow ( 10 , $ round ) ; $ number = round ( $ size * $ arr ) / $ arr ; } else { $ number = $ size ; } return str_replace ( '.' , $ dec_delimiter , $ number ) . ' ' . self :: $ FILESIZE_ORDERED_UNITS [ $ count ] ; }
Returns a formatted file size in bytes or derived unit
24,315
public static function isCommonImage ( $ file_name ) { if ( ! self :: isCommonFile ( $ file_name ) || $ file_name { 0 } === '.' || @ is_dir ( $ file_name ) ) { return false ; } $ ext = self :: getExtensionName ( $ file_name ) ; return ( $ ext ? in_array ( strtolower ( $ ext ) , self :: $ COMMON_IMG_EXTS ) : false ) ; }
Tests if a file name seems to have a common image s extension
24,316
public static function isCommonVideo ( $ file_name ) { if ( ! self :: isCommonFile ( $ file_name ) || $ file_name { 0 } === '.' || @ is_dir ( $ file_name ) ) { return false ; } $ ext = self :: getExtensionName ( $ file_name ) ; return ( $ ext ? in_array ( strtolower ( $ ext ) , self :: $ COMMON_VIDEOS_EXTS ) : false ) ; }
Tests if a file name seems to have a common video s extension
24,317
public function limitWords ( $ string , $ limit = false , $ end = '...' ) { $ words = explode ( " " , $ string ) ; if ( count ( $ words ) <= $ limit ) { return $ string ; } $ return = [ ] ; for ( $ wordCount = 0 ; $ wordCount < $ limit ; $ wordCount ++ ) { $ return [ ] = $ words [ $ wordCount ] ; } $ return [ ] = $ end ; return implode ( " " , $ return ) ; }
Limits a string to a certain number of words
24,318
public function injectParams ( $ string , $ params = array ( ) ) { $ links = preg_split ( '#(<a\b[^>]+>)#' , $ string , - 1 , PREG_SPLIT_DELIM_CAPTURE ) ; $ old = $ links ; foreach ( $ links as & $ match ) { if ( preg_match ( '/<a\b/' , $ match ) && ! preg_match ( '/(?:#|mailto)/' , $ match ) ) { preg_match ( '/^([^"]+")([^"]+)/' , $ match , $ matches ) ; if ( $ matches ) { $ link = html_entity_decode ( $ matches [ 2 ] ) ; if ( strpos ( $ link , "?" ) === false ) { $ link .= "?" ; } else { $ link .= "&" ; } $ link .= http_build_query ( $ params ) ; $ match = str_replace ( $ matches [ 2 ] , $ link , $ match ) ; } } } $ string = str_replace ( $ old , $ links , $ string ) ; return $ string ; }
Injects GET params in links
24,319
public function relativeToAbsolute ( $ string , $ base ) { $ matches = preg_split ( '#(<(a|img)\b[^>]+>)#' , $ string , - 1 , PREG_SPLIT_DELIM_CAPTURE ) ; $ old = $ matches ; foreach ( $ matches as & $ match ) { if ( preg_match ( '/<(a|img)\b/' , $ match ) && ! preg_match ( '/(?:http|#|mailto)/' , $ match ) ) { $ match = preg_replace ( '/^([^"]+")([^"]+)/' , '$1' . $ base . '$2' , $ match ) ; } } $ string = str_replace ( $ old , $ matches , $ string ) ; return $ string ; }
Converts all relative hrefs and image srcs to absolute
24,320
private function internalSanitizeHooks ( $ key , $ value , $ type = 'input' ) { $ hook = trim ( strtolower ( $ type ) ) == 'input' ? 'sanitizeInputHook' : 'sanitizeOutputHook' ; return method_exists ( $ this , $ hook ) ? $ this -> $ hook ( $ key , $ value ) : $ value ; }
this function have the base logic of sanitizing an array element base on both of key and value and then return the sanitized value
24,321
private function internalFilterHooks ( $ key , $ value , $ type = 'input' ) { $ hook = '' ; switch ( trim ( strtolower ( $ type ) ) ) { case 'output' : $ hook = 'filterOutputHook' ; break ; case 'remove' : $ hook = 'filterRemoveHook' ; break ; case 'input' : $ hook = 'filterInputHook' ; break ; } if ( $ hook && method_exists ( $ this , $ hook ) ) { $ result = $ this -> $ hook ( $ key , $ value ) ; if ( $ result !== true && $ result !== null ) { return false ; } } return true ; }
this function have th base logic of filtering input and output base on both of key and value
24,322
private function internalChangingHooks ( $ key , $ value , $ oldValue = null , $ type = 'insert' ) { switch ( trim ( strtolower ( $ type ) ) ) { case 'update' : $ hook = 'updateHook' ; if ( method_exists ( $ this , $ hook ) ) { $ this -> $ hook ( $ key , $ value , $ oldValue ) ; } break ; case 'remove' : $ hook = 'removeHook' ; if ( method_exists ( $ this , $ hook ) ) { $ this -> $ hook ( $ key , $ oldValue ) ; } break ; case 'insert' : $ hook = 'insertHook' ; if ( method_exists ( $ this , $ hook ) ) { $ this -> $ hook ( $ key , $ value ) ; } break ; } }
check for existing of changing element hook method in current object and send the key the value and the old value of to it . tis helps you to have an active array
24,323
protected static function phpFile_item ( & $ code , $ array , $ ident = 4 ) { $ sident = str_pad ( '' , $ ident , ' ' ) ; foreach ( $ array as $ key => $ value ) { $ code .= $ sident ; $ code .= '\'' . $ key . '\' => ' ; if ( is_array ( $ value ) ) { $ code .= '[' . "\r\n" ; self :: phpFile_item ( $ code , $ value , $ ident + 4 ) ; $ code .= $ sident ; $ code .= '],' . "\r\n" ; } else { $ value = str_replace ( "\r\n" , "\n\r" . $ sident , $ value ) ; $ value = str_replace ( "\n\r" , "\r\n" , $ value ) ; $ code .= '"' . $ value . '",' . "\r\n" ; } } }
Auxilia na geracao do arquivo PHP de um array .
24,324
public function load ( $ file ) { $ file_name = $ this -> _config_path . $ file . '.php' ; if ( is_file ( $ file_name ) and ! array_key_exists ( $ file , $ this -> _loaded ) ) { $ this -> _config = array_merge ( require $ file_name , $ this -> _config ) ; $ this -> _loaded [ $ file ] = true ; return true ; } elseif ( ! is_file ( $ file_name ) ) { throw new \ QuickCacheException ( 'The config file "' . $ file . '" does not exist' ) ; } }
Load a config file
24,325
public function get ( $ key = false ) { return isset ( $ this -> _config [ $ key ] ) ? $ this -> _config [ $ key ] : null ; }
Get a config value by key
24,326
public function authenticate ( ) { $ e = $ this -> getEvent ( ) ; $ result = new Result ( $ e -> getCode ( ) , $ e -> getIdentity ( ) , $ e -> getMessages ( ) ) ; $ this -> resetAdapters ( ) ; return $ result ; }
Returns the authentication result
24,327
public function encode ( $ value , $ optionsMask = 0 ) { $ encoded = json_encode ( $ value , $ optionsMask ) ; $ lastError = json_last_error ( ) ; if ( $ lastError !== JSON_ERROR_NONE ) { throw new JsonException ( $ this -> translateErrorMessage ( $ lastError ) ) ; } return $ encoded ; }
Encode a PHP value as a JSON string .
24,328
public function setStructurePrototype ( $ structurePrototype ) { if ( $ structurePrototype instanceof MapperAwareInterface ) { $ structurePrototype -> setMapper ( $ this ) ; } $ this -> structurePrototype = $ structurePrototype ; return $ this ; }
Set structure prototype
24,329
public function autodiscover ( $ path ) { if ( ! is_array ( $ path ) ) { $ path = ( array ) $ path ; } foreach ( $ path as $ apps_dir ) { if ( is_dir ( $ apps_dir ) ) { if ( ( $ dh = opendir ( $ apps_dir ) ) !== false ) { while ( ( $ name = readdir ( $ dh ) ) !== false ) { if ( $ name { 0 } == '.' || $ name == 'Core' || is_file ( $ apps_dir . '/' . $ name ) ) { continue ; } $ app = $ this -> getAppInstance ( $ name ) ; } closedir ( $ dh ) ; } } } }
Autodiscovers installed apps in the given path
24,330
public function init ( ServletConfigInterface $ servletConfig ) { parent :: init ( $ servletConfig ) ; $ this -> applicationContext = $ this -> getServletContext ( ) -> getApplication ( ) ; $ this -> initialContext = new InitialContext ( ) ; $ this -> initialContext -> injectApplication ( $ this -> applicationContext ) ; $ this -> logger = $ this -> applicationContext -> getInitialContext ( ) -> getSystemLogger ( ) ; $ this -> logger -> debug ( 'Initializing Servlet ' . str_replace ( "\n" , " - " , $ this -> servletInfo ) ) ; if ( file_exists ( __DIR__ . "/DispatcherServlet.properties" ) && is_readable ( __DIR__ . "/DispatcherServlet.properties" ) ) { $ this -> defaultStrategies = new Properties ( ) ; try { $ this -> defaultStrategies -> load ( __DIR__ . "/DispatcherServlet.properties" ) ; } catch ( PropertyFileParseException $ exc ) { $ this -> logger -> error ( "Could not read default strategies" ) ; } } $ this -> initStrategies ( ) ; }
Overridden init function to initialize application context
24,331
protected function initHandlerMappings ( ) { $ this -> logger -> debug ( 'Initializing HandlerMappings.' ) ; $ this -> handlerMappings = array ( ) ; if ( $ this -> detectAllHandlerMappings ) { $ this -> logger -> debug ( 'Scanning beans for HandlerMappings.' ) ; $ beans = BeanUtils :: beansOfType ( $ this -> applicationContext , "Ocelot\\Mvc\\Web\\Servlet\\HandlerMapping" ) ; if ( ! empty ( $ beans ) ) { $ this -> handlerMappings = array_values ( $ beans ) ; } } else { $ this -> logger -> debug ( 'Looking up HandlerMapping bean by name.' ) ; $ handlerMapping = $ this -> initialContext -> lookup ( self :: HANDLER_MAPPING_BEAN_NAME ) ; if ( $ handlerMapping != null && $ handlerMapping instanceof HandlerMapping ) { $ this -> handlerMappings = array ( $ handlerMapping ) ; } } if ( empty ( $ this -> handlerMappings ) ) { $ this -> logger -> warning ( 'Could not find any bean of type HandlerMapping, falling back to default strategy.' ) ; $ this -> viewResolvers = $ this -> getDefaultStrategies ( "Ocelot\\Mvc\\Web\\Servlet\\HandlerMapping" ) ; } }
Initialize the HandlerMappings used by this class .
24,332
protected function initHandlerAdapters ( ) { $ this -> logger -> debug ( 'Initializing HandlerAdapters.' ) ; $ this -> handlerAdapters = array ( ) ; if ( $ this -> detectAllHandlerAdapters ) { $ this -> logger -> debug ( 'Scanning beans for HandlerAdapters.' ) ; $ beans = BeanUtils :: beansOfType ( $ this -> applicationContext , "Ocelot\\Mvc\\Web\\Servlet\\HandlerAdapter" ) ; if ( ! empty ( $ beans ) ) { $ this -> handlerAdapters = array_values ( $ beans ) ; } } else { $ this -> logger -> debug ( 'Looking up HandlerAdapter bean by name.' ) ; $ handlerAdapter = $ this -> initialContext -> lookup ( self :: HANDLER_ADAPTER_BEAN_NAME ) ; if ( $ handlerAdapter != null && $ handlerAdapter instanceof HandlerAdapter ) { $ this -> handlerAdapters = array ( $ handlerAdapter ) ; } } if ( empty ( $ this -> handlerAdapters ) ) { $ this -> logger -> warning ( 'Could not find any bean of type HandlerAdapter, falling back to default strategy.' ) ; $ this -> viewResolvers = $ this -> getDefaultStrategies ( "Ocelot\\Mvc\\Web\\Servlet\\HandlerAdapter" ) ; } }
Initialize the HandlerAdapters used by this class .
24,333
protected function initViewResolvers ( ) { $ this -> logger -> debug ( 'Initializing ViewResolvers.' ) ; $ this -> viewResolvers = array ( ) ; if ( $ this -> detectAllViewResolvers ) { $ this -> logger -> debug ( 'Scanning beans for ViewResolvers.' ) ; $ beans = BeanUtils :: beansOfType ( $ this -> applicationContext , "Ocelot\\Mvc\\Web\\Servlet\\ViewResolver" ) ; if ( ! empty ( $ beans ) ) { $ this -> viewResolvers = array_values ( $ beans ) ; } } else { $ this -> logger -> debug ( 'Looking up ViewResolver bean by name.' ) ; $ viewResolver = $ this -> initialContext -> lookup ( self :: VIEW_RESOLVER_BEAN_NAME ) ; if ( $ viewResolver != null && $ viewResolver instanceof ViewResolver ) { $ this -> viewResolvers = array ( $ viewResolver ) ; } } if ( empty ( $ this -> viewResolvers ) ) { $ this -> logger -> warning ( 'Could not find any bean of type ViewResolver, falling back to default strategy.' ) ; $ this -> viewResolvers = $ this -> getDefaultStrategies ( "Ocelot\\Mvc\\Web\\Servlet\\ViewResolver" ) ; } }
Initialize the ViewResolvers used by this class .
24,334
public function service ( ServletRequestInterface $ servletRequest , ServletResponseInterface $ servletResponse ) { $ logger = $ servletRequest -> getContext ( ) -> getInitialContext ( ) -> getSystemLogger ( ) ; $ logger -> debug ( 'Starting dispatch process for a new http request.' ) ; $ attributeSnapshot = array_merge ( array ( ) , $ servletRequest -> getParameterMap ( ) ) ; try { $ this -> dispatch ( $ servletRequest , $ servletResponse ) ; } catch ( \ Exception $ ex ) { $ logger -> error ( 'Dispatch failed' , $ ex ) ; } }
Entry point for requests . Dispatch the request to a controller here
24,335
protected function dispatch ( Request $ servletRequest , Response $ servletResponse ) { $ mapperHandler = null ; try { $ mv = null ; $ dispatchException = null ; try { $ mappedHandler = $ this -> getHandler ( $ servletRequest ) ; if ( $ mappedHandler == null || $ mappedHandler -> getHandler ( ) == null ) { $ this -> noHandlerFound ( $ servletRequest , $ servletResponse ) ; return ; } $ ha = $ this -> getHandlerAdapter ( $ mappedHandler -> getHandler ( ) ) ; if ( ! $ mappedHandler -> applyPreHandle ( $ servletRequest , $ servletResponse ) ) { return ; } $ mv = $ ha -> handle ( $ servletRequest , $ servletResponse , $ mappedHandler -> getHandler ( ) ) ; $ mappedHandler -> applyPostHandle ( $ servletRequest , $ servletResponse , $ mv ) ; } catch ( \ Exception $ ex ) { $ dispatchException = $ ex ; } $ this -> processDispatchResult ( $ servletRequest , $ servletResponse , $ mappedHandler , $ mv , $ dispatchException ) ; } catch ( \ Exception $ ex ) { $ this -> triggerAfterCompletion ( $ servletRequest , $ servletResponse , $ mappedHandler , $ ex ) ; } }
Internal dispatch function that gets called by service
24,336
protected function getHandler ( ServletRequestInterface $ servletRequest ) { foreach ( $ this -> handlerMappings as $ handlerMapping ) { $ handler = $ handlerMapping -> getHandler ( $ servletRequest ) ; if ( $ handler != null ) { return $ handler ; } } return null ; }
Return the HandlerExecutionChain for this request
24,337
protected function noHandlerFound ( Request $ servletRequest , Response $ servletResponse ) { $ this -> logger -> warning ( "No mapping found for HTTP request with URI [" . $ servletRequest -> getRequestUri ( ) . "]" ) ; throw new \ Exception ( "No mapping found for HTTP request with URI [" . $ servletRequest -> getRequestUri ( ) . "]" ) ; }
No handler found - > throw exception
24,338
protected function getHandlerAdapter ( $ handler ) { foreach ( $ this -> handlerAdapters as $ ha ) { if ( $ ha -> supports ( $ handler ) ) { return $ ha ; } } throw new \ Exception ( "No adapter for handler [" . get_class ( $ handler ) . "]: The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler." ) ; }
Return the HandlerAdapter for this handler object .
24,339
protected function processDispatchResult ( Request $ request , Response $ response , HandlerExecutionChain $ mappedHandler , ModelAndView $ mv = null , \ Exception $ ex = null ) { if ( $ mv != null && ! $ mv -> wasCleared ( ) ) { $ this -> render ( $ mv , $ request , $ response ) ; } if ( $ mappedHandler != null ) { $ mappedHandler -> triggerAfterCompletion ( $ request , $ response , $ ex ) ; } }
Handle the result of a handler selection and handler invocation which is either a ModelAndView or an Exception to be resolved to a ModelAndView
24,340
protected function render ( ModelAndView $ mv , Request $ request , Response $ response ) { $ view = null ; if ( $ mv -> isReference ( ) ) { $ view = resolveViewName ( $ mv -> getViewName ( ) , $ mv -> getModelMap ( ) , null , $ request ) ; if ( $ view == null ) { throw new \ Exception ( "Could not resolve view with name '" . $ mv -> getViewName ( ) . "'." ) ; } } else { $ view = $ mv -> getView ( ) ; if ( $ view == null ) { throw new \ Exception ( "ModelAndView neither contains a view name nor a View object." ) ; } } try { $ view -> render ( $ mv -> getModelMap ( ) , $ request , $ response ) ; } catch ( \ Exception $ ex ) { $ this -> logger -> debug ( "Error rendering view." ) ; throw $ ex ; } }
Render the given ModelAndView .
24,341
protected function triggerAfterCompletion ( Request $ request , Response $ response , HandlerExecutionChain $ mappedHandler , \ Exception $ ex ) { if ( $ mappedHandler != null ) { $ mappedHandler -> triggerAfterCompletion ( $ request , $ response , $ ex ) ; } throw $ ex ; }
Triggers after completion of the mappedHandler if any
24,342
public function verifyEmail ( User $ user , $ token ) { $ this -> _prepareEmail ( $ user , __d ( 'wasabi_core' , 'Verify your email address' ) ) ; $ this -> _email -> template ( 'Wasabi/Core.User/verify' ) ; $ this -> _email -> viewVars ( [ 'user' => $ user , 'verifyEmailLink' => [ 'plugin' => 'Wasabi/Core' , 'controller' => 'Users' , 'action' => 'verifyByToken' , 'token' => $ token ] , 'instanceName' => Wasabi :: getInstanceName ( ) ] ) ; }
Send a verify email to the user so that he can verify his email address .
24,343
public function verifyAndResetPasswordEmail ( User $ user , $ token ) { $ this -> _prepareEmail ( $ user , __d ( 'wasabi_core' , 'Verify your email address' ) ) ; $ this -> _email -> template ( 'Wasabi/Core.User/verify' ) ; $ this -> _email -> viewVars ( [ 'user' => $ user , 'verifyEmailLink' => [ 'plugin' => null , 'controller' => 'Backend/Users' , 'action' => 'verifyByTokenResetPassword' , 'token' => $ token ] , 'instanceName' => Wasabi :: getInstanceName ( ) ] ) ; }
Send a verify email to the user that contains a link to verify his email address and setup his password . This mail is sent whenever an Admin creates a new user via the backend .
24,344
public function verifiedEmail ( User $ user ) { $ this -> _prepareEmail ( $ user , __d ( 'wasabi_core' , 'Email address verified' ) ) ; $ this -> _email -> template ( 'Wasabi/Core.User/verfied' ) ; $ this -> _email -> viewVars ( [ 'user' => $ user , 'instanceName' => Wasabi :: getInstanceName ( ) ] ) ; }
Send a verified email to the user when his email address has been verified .
24,345
protected function _prepareEmail ( User $ user , $ subject ) { $ this -> layout ( 'Wasabi/Core.responsive' ) ; $ this -> _email -> transport ( 'default' ) ; $ this -> _email -> emailFormat ( 'both' ) ; $ this -> _email -> from ( Wasabi :: getSenderEmail ( ) , Wasabi :: getSenderName ( ) ) ; $ this -> _email -> to ( $ user -> email , $ user -> username ) ; $ this -> _email -> subject ( $ subject ) ; $ this -> _email -> helpers ( [ 'Email' => [ 'className' => 'Wasabi/Core.Email' ] ] ) ; }
Prepare the UserMailer Email instance .
24,346
public function send ( $ action , $ args = [ ] , $ headers = [ ] ) { $ results = [ ] ; try { $ results = parent :: send ( $ action , $ args , $ headers ) ; } catch ( \ Exception $ e ) { Log :: write ( LOG_CRIT , 'Emails cannot be sent: ' . $ e -> getMessage ( ) , $ this -> _email ) ; } return $ results ; }
Wrap the original send to catch erros and log them .
24,347
public function getItems ( $ offset , $ itemCountPerPage ) { $ this -> cursor -> skip ( $ offset ) ; $ this -> cursor -> limit ( $ itemCountPerPage ) ; $ resultSet = clone $ this -> resultSetPrototype ; $ resultSet -> initialize ( $ this -> cursor ) ; return $ resultSet ; }
Returns an result set of items for a page .
24,348
public function getModel ( ) { $ collection = $ this -> getCollection ( ) ; $ model = $ collection -> getModel ( ) ; $ model -> setEntityManager ( $ this ) ; return $ model ; }
Get the model associated with the collection .
24,349
public function getStatementManager ( $ statementClass = Simple :: class ) { $ statementManager = new $ statementClass ( $ this -> config , $ this ) ; $ collectionClass = $ this -> getCollectionClass ( ) ; if ( ! $ statementManager instanceof StatementManager ) { throw new \ Exception ( $ statementClass . ' is not an instance of Deasil\CEF\StatementManager.' ) ; } $ statementManager -> setResultContainerClass ( $ collectionClass ) ; return $ statementManager ; }
Statement Manager Factory .
24,350
protected function getRouteFromRequest ( Request $ request ) { $ attributes = $ request -> attributes -> get ( '_route_params' ) ; if ( isset ( $ attributes [ RouteObjectInterface :: ROUTE_OBJECT ] ) && ( $ attributes [ RouteObjectInterface :: ROUTE_OBJECT ] instanceof RouteInterface ) ) { return $ attributes [ RouteObjectInterface :: ROUTE_OBJECT ] ; } return null ; }
Get route from request .
24,351
protected static function collapseDotFolder ( $ root , $ part , & $ canonicalParts ) { if ( '.' === $ part ) { return ; } if ( '..' === $ part && count ( $ canonicalParts ) > 0 && '..' !== $ canonicalParts [ count ( $ canonicalParts ) - 1 ] ) { array_pop ( $ canonicalParts ) ; return ; } if ( '..' !== $ part || '' === $ root ) { $ canonicalParts [ ] = $ part ; } }
Collapse dot folder . .. if possible
24,352
public static function isDirEmpty ( string $ path ) : bool { if ( ! self :: isReadable ( $ path ) ) { return false ; } $ result = true ; $ handle = opendir ( $ path ) ; while ( false !== ( $ entry = readdir ( $ handle ) ) ) { if ( ! self :: isDotDir ( $ entry ) ) { $ result = false ; break ; } } closedir ( $ handle ) ; return $ result ; }
Check if a directory is empty in efficent way . Check hidden files too .
24,353
public function findByNamesWithDependencies ( array $ modNames ) : array { $ result = [ ] ; if ( count ( $ modNames ) > 0 ) { $ queryBuilder = $ this -> entityManager -> createQueryBuilder ( ) ; $ queryBuilder -> select ( [ 'm' , 'd' , 'dm' ] ) -> from ( Mod :: class , 'm' ) -> leftJoin ( 'm.dependencies' , 'd' ) -> leftJoin ( 'd.requiredMod' , 'dm' ) -> andWhere ( 'm.name IN (:modNames)' ) -> setParameter ( 'modNames' , array_values ( $ modNames ) ) ; $ result = $ queryBuilder -> getQuery ( ) -> getResult ( ) ; } return $ result ; }
Finds all mods with the specified names fetching their dependencies as well .
24,354
public function count ( array $ modCombinationIds = [ ] ) : int { $ queryBuilder = $ this -> entityManager -> createQueryBuilder ( ) ; $ queryBuilder -> select ( 'COUNT(DISTINCT m.id) AS numberOfMods' ) -> from ( Mod :: class , 'm' ) ; if ( count ( $ modCombinationIds ) > 0 ) { $ queryBuilder -> innerJoin ( 'm.combinations' , 'mc' ) -> andWhere ( 'mc.id IN (:modCombinationIds)' ) -> setParameter ( 'modCombinationIds' , array_values ( $ modCombinationIds ) ) ; } try { $ result = ( int ) $ queryBuilder -> getQuery ( ) -> getSingleScalarResult ( ) ; } catch ( NonUniqueResultException $ e ) { $ result = 0 ; } return $ result ; }
Counts the mods .
24,355
public function getCurrentCaller ( ) { if ( is_null ( $ this -> currentCaller ) ) { $ loginToken = $ this -> session -> getLoginToken ( ) ; try { $ this -> currentCaller = $ this -> identifier -> identifyByLoginToken ( $ loginToken ) ; } catch ( IdentificationFailed $ e ) { $ this -> session -> destroy ( ) ; } } return $ this -> currentCaller ; }
Returns the current caller
24,356
private function checkIdField ( ) { if ( is_null ( $ this -> headers ) ) { return ; } if ( in_array ( $ this -> idField , $ this -> headers ) ) { return ; } foreach ( $ this -> headers as $ header ) { if ( strtolower ( $ this -> idField ) == strtolower ( $ header ) ) { $ this -> setIdField ( $ header ) ; } } }
Check the header line for variations on the default ID field name fixing the case of the ID field .
24,357
public function toAssociative ( $ data ) { foreach ( $ data as $ i => $ value ) { $ headerName = $ this -> headers [ $ i ] ; $ data [ $ headerName ] = $ value ; unset ( $ data [ $ i ] ) ; } return $ data ; }
Converts an indexed array of data into an associative array with field names .
24,358
public function toIndexed ( $ data , $ fillMissing = false ) { foreach ( $ data as $ key => $ value ) { if ( ! in_array ( $ key , $ this -> headers ) ) { throw new InvalidFieldException ( $ key ) ; } $ headerIndex = ( int ) array_search ( $ key , $ this -> headers ) ; $ data [ $ headerIndex ] = $ value ; unset ( $ data [ $ key ] ) ; } ksort ( $ data ) ; if ( $ fillMissing ) { $ data = $ this -> fillMissing ( $ data ) ; } return $ data ; }
Converts an associative array into an indexed array according to the currently stored headers .
24,359
private function fillMissing ( $ data , $ existingData = [ ] ) { if ( $ this -> isAssoc ( $ data ) ) { foreach ( $ this -> headers as $ header ) { if ( ! isset ( $ data [ $ header ] ) ) { $ replaceWith = isset ( $ existingData [ $ header ] ) ? $ existingData [ $ header ] : "" ; $ data [ $ header ] = $ replaceWith ; } } } else { end ( $ this -> headers ) ; for ( $ i = 0 , $ max = key ( $ this -> headers ) ; $ i <= $ max ; $ i ++ ) { if ( ! isset ( $ data [ $ i ] ) ) { $ replaceWith = isset ( $ existingData [ $ i ] ) ? $ existingData [ $ i ] : "" ; $ data [ $ i ] = $ replaceWith ; } } ksort ( $ data ) ; } return $ data ; }
Fills any missing keys with blank fields or merging with an existing data set if provided .
24,360
public function get ( $ index = null , $ fetchFields = [ ] ) { $ this -> lock ( ) ; if ( is_null ( $ index ) ) { $ index = $ this -> file -> key ( ) ; } else { if ( ! ( is_int ( $ index ) || ctype_digit ( $ index ) ) || $ index < 0 ) { throw new InvalidIndexException ( $ index ) ; } $ index = ( int ) $ index ; } if ( $ index <= $ this -> file -> key ( ) + 1 ) { $ this -> file -> rewind ( ) ; } while ( $ index >= $ this -> file -> key ( ) ) { $ this -> file -> next ( ) ; } if ( ! $ this -> file -> valid ( ) ) { $ this -> file -> flock ( LOCK_UN ) ; return false ; } $ data = $ this -> file -> current ( ) ; $ this -> file -> flock ( LOCK_UN ) ; $ row = $ this -> toAssociative ( $ data ) ; return $ row ; }
Returns the row at the given index or the current file pointer position if not supplied . Optionally supply the headers to retrieve ignoring any others .
24,361
public function getAll ( ) { $ this -> file -> rewind ( ) ; $ data = [ ] ; while ( false !== $ row = $ this -> get ( ) ) { $ data [ ] = $ row ; } return $ data ; }
Returns an array of all rows .
24,362
public function getBy ( $ fieldName , $ fieldValue , $ fetchFields = [ ] ) { $ result = $ this -> getAllBy ( $ fieldName , $ fieldValue , $ fetchFields , 1 ) ; if ( isset ( $ result [ 0 ] ) ) { return $ result [ 0 ] ; } else { return null ; } }
Returns the first element in the matching rows without iterating over the whole data .
24,363
public function getIdField ( ) { if ( ! empty ( $ this -> headers ) && ! in_array ( $ this -> idField , $ this -> headers ) ) { throw new InvalidFieldException ( $ this -> idField ) ; } return $ this -> idField ; }
Retrieves the internally set field used for ID . By default this is ID but if there is no field with that name then this function returns null .
24,364
public function add ( $ row ) { $ this -> changesMade = true ; $ rowColumns = $ row ; $ rowAssociative = $ row ; $ this -> lock ( ) ; if ( $ this -> isAssoc ( $ row ) ) { if ( ! $ this -> headers ) { $ this -> headers = array_keys ( $ row ) ; $ this -> file -> fputcsv ( $ this -> headers ) ; } $ rowColumns = $ this -> toIndexed ( $ row , true ) ; } else { $ rowAssociative = $ this -> toAssociative ( $ row ) ; } if ( ! $ this -> headers ) { throw new HeadersNotSetException ( ) ; } $ rowColumns = $ this -> fillMissing ( $ rowColumns ) ; $ this -> file -> fseek ( 0 , SEEK_END ) ; $ this -> file -> fputcsv ( $ rowColumns ) ; $ this -> file -> fflush ( ) ; $ this -> file -> flock ( LOCK_UN ) ; return $ rowAssociative ; }
Adds a single row to the CSV file the values according to associative array keys matching the currently stored headers . If there are no headers stored the headers will take the form of the current associative array s keys in the order they exist in the array .
24,365
private function isAssoc ( $ array ) { $ allIntegerKeys = true ; foreach ( $ array as $ key => $ value ) { if ( ! is_integer ( $ key ) ) { $ allIntegerKeys = false ; break ; } } return $ allIntegerKeys === false ; }
Checks whether a given array is associative or indexed .
24,366
public function attach ( ObserverInterface $ observer ) : void { $ key = spl_object_hash ( $ observer ) ; if ( array_key_exists ( $ key , $ this -> observers ) ) { throw new ObservatoryException ( 'Provided observer already known, hash: ' . $ key ) ; } $ this -> observers [ $ key ] = $ observer ; }
attaches an observer to the observable .
24,367
public function detach ( ObserverInterface $ observer ) : void { $ key = spl_object_hash ( $ observer ) ; unset ( $ this -> observers [ $ key ] ) ; }
detaches an observer from the observable .
24,368
protected function isDispatched ( ) { $ param = [ 'result' => $ this -> result ] ; if ( $ this -> trigger ( self :: EVENT_BEFORE_DISPATCH , $ param ) && $ this -> executeHandler ( ) && $ this -> trigger ( self :: EVENT_AFTER_DISPATCH , $ param ) ) { return true ; } return false ; }
Real dispatching process
24,369
protected function executeHandler ( ) { try { $ handler = $ this -> result -> getHandler ( ) ; $ callable = $ this -> getResolver ( ) -> resolve ( $ handler ) ; if ( $ this -> result -> getRoute ( ) ) { return $ this -> callableWithRoute ( $ callable ) ; } else { call_user_func ( $ callable , $ this -> result ) ; return true ; } } catch ( \ Exception $ e ) { $ this -> result -> setHandler ( null ) ; return false ; } }
Execute handler of the result
24,370
protected function callableWithRoute ( callable $ callable ) { $ route = $ this -> result -> getRoute ( ) ; $ param = [ 'result' => $ this -> result ] ; if ( $ route -> trigger ( Route :: EVENT_BEFORE_HANDLER , $ param ) ) { call_user_func ( $ callable , $ this -> result ) ; $ route -> trigger ( Route :: EVENT_AFTER_HANDLER , $ param ) ; return true ; } $ this -> result -> setHandler ( null ) ; return false ; }
Execute the callable with route events
24,371
protected function defaultHandler ( ) { $ status = $ this -> result -> getStatus ( ) ; $ handler = $ this -> result -> getHandler ( ) ? : $ this -> getHandler ( $ status ) ; if ( $ handler ) { $ param = [ 'result' => $ this -> result ] ; $ callable = $ this -> getResolver ( ) -> resolve ( $ handler ) ; if ( $ this -> trigger ( self :: EVENT_BEFORE_HANDLER , $ param ) ) { call_user_func ( $ callable , $ this -> result ) ; $ this -> trigger ( self :: EVENT_AFTER_HANDLER , $ param ) ; } } return false ; }
Execute dispatcher level handler
24,372
public function link ( Model $ model ) { $ this -> getLinked ( ) -> flush ( ) -> append ( $ model ) ; $ this -> getPrimaryModel ( ) -> set ( $ this -> getPrimaryForeignKey ( ) , $ model -> id ( ) ) ; return $ this ; }
Only one record at a time can be linked in a belongs to relation . Also include the ID from the foreign model as an attribute on the primary model .
24,373
public function unlink ( Model $ model ) { $ this -> getUnlinked ( ) -> flush ( ) -> append ( $ model ) ; $ this -> getPrimaryModel ( ) -> set ( $ this -> getPrimaryForeignKey ( ) , null ) ; return $ this ; }
Only one record at a time can be unlinked in a belongs to relation . Also reset the foreign key attribute in the primary model .
24,374
public function setCompletedStatus ( $ value ) { if ( empty ( $ value ) ) { $ this -> completed = null ; } elseif ( empty ( $ this -> completed ) ) { $ this -> completed = DateHelper :: date ( $ this -> dbDateFormat . " " . $ this -> dbTimeFormat , time ( ) ) ; } }
Set completed status .
24,375
static public function bindClass ( $ interface_or_class , $ class , $ init_function = null ) { if ( empty ( $ class ) ) { throw new \ Exception ( "Bound class is empty!" ) ; } if ( empty ( $ interface_or_class ) ) { throw new \ Exception ( "Bound interface or class is empty!" ) ; } if ( ! interface_exists ( $ interface_or_class ) && ! class_exists ( $ interface_or_class ) ) { throw new \ Exception ( sprintf ( "The interface or class '%s' does not exist!" , $ interface_or_class ) ) ; } if ( ! class_exists ( $ class ) ) { throw new \ Exception ( sprintf ( "The class '%s' does not exist!" , $ class ) ) ; } try { $ ic = new \ ReflectionClass ( $ interface_or_class ) ; $ c = new \ ReflectionClass ( $ class ) ; } catch ( \ Exception $ ex ) { throw new \ Exception ( $ ex -> getMessage ( ) ) ; } if ( ! $ c -> isInstantiable ( ) ) { throw new \ Exception ( sprintf ( "The class '%s' is not instantiable!" , $ c -> getName ( ) ) ) ; } if ( $ c != $ ic ) { if ( ! $ c -> isSubclassOf ( $ ic ) ) { throw new \ Exception ( sprintf ( "The class '%s' does not implement the interface '%s'!" , $ c -> getName ( ) , $ ic -> getName ( ) ) ) ; } } $ f = null ; if ( $ init_function !== null ) { if ( ! is_callable ( $ init_function ) ) { throw new \ Exception ( sprintf ( "'%s' is not a function!" , $ init_function ) ) ; } try { $ f = new \ ReflectionFunction ( $ init_function ) ; } catch ( \ Exception $ ex ) { throw new \ Exception ( $ ex -> getMessage ( ) ) ; } } self :: $ itable [ $ ic -> getName ( ) ] = [ "class" => $ c , "init_function" => $ f ] ; }
Binds a class to an interface or a parent class .
24,376
public static function Bp00 ( $ date1 , $ date2 , array & $ rb , array & $ rp , array & $ rbp ) { $ EPS0 = 84381.448 * DAS2R ; $ t ; $ dpsibi ; $ depsbi ; $ dra0 ; $ psia77 ; $ oma77 ; $ chia ; $ dpsipr ; $ depspr ; $ psia ; $ oma ; $ rbw = [ ] ; $ t = ( ( $ date1 - DJ00 ) + $ date2 ) / DJC ; IAU :: Bi00 ( $ dpsibi , $ depsbi , $ dra0 ) ; $ psia77 = ( 5038.7784 + ( - 1.07259 + ( - 0.001147 ) * $ t ) * $ t ) * $ t * DAS2R ; $ oma77 = $ EPS0 + ( ( 0.05127 + ( - 0.007726 ) * $ t ) * $ t ) * $ t * DAS2R ; $ chia = ( 10.5526 + ( - 2.38064 + ( - 0.001125 ) * $ t ) * $ t ) * $ t * DAS2R ; IAU :: Pr00 ( $ date1 , $ date2 , $ dpsipr , $ depspr ) ; $ psia = $ psia77 + $ dpsipr ; $ oma = $ oma77 + $ depspr ; IAU :: Ir ( $ rbw ) ; IAU :: Rz ( $ dra0 , $ rbw ) ; IAU :: Ry ( $ dpsibi * sin ( $ EPS0 ) , $ rbw ) ; IAU :: Rx ( - $ depsbi , $ rbw ) ; IAU :: Cr ( $ rbw , $ rb ) ; IAU :: Ir ( $ rp ) ; IAU :: Rx ( $ EPS0 , $ rp ) ; IAU :: Rz ( - $ psia , $ rp ) ; IAU :: Rx ( - $ oma , $ rp ) ; IAU :: Rz ( $ chia , $ rp ) ; IAU :: Rxr ( $ rp , $ rbw , $ rbp ) ; return ; }
- - - - - - - - i a u B p 0 0 - - - - - - - -
24,377
public static function enable ( $ errorReportingLevel = null , $ displayErrors = true ) { if ( static :: $ enabled ) { return ; } static :: $ enabled = true ; if ( null !== $ errorReportingLevel ) { error_reporting ( $ errorReportingLevel ) ; } else { error_reporting ( - 1 ) ; } if ( 'cli' !== PHP_SAPI ) { ini_set ( 'display_errors' , 0 ) ; ExceptionHandler :: register ( ) ; } elseif ( $ displayErrors && ( ! ini_get ( 'log_errors' ) || ini_get ( 'error_log' ) ) ) { ini_set ( 'display_errors' , 1 ) ; } if ( $ displayErrors ) { ErrorHandler :: register ( new ErrorHandler ( new BufferingLogger ( ) ) ) ; } else { ErrorHandler :: register ( ) -> throwAt ( 0 , true ) ; } DebugClassLoader :: enable ( ) ; }
Enables the debug tools .
24,378
public function addCss ( $ file , $ path = '/css' , $ attr = [ ] ) { $ attr = array_merge ( [ 'rel' => 'stylesheet' ] , $ attr ) ; $ output = [ ] ; foreach ( $ attr as $ name => $ value ) { $ output [ ] = "{$name}=\"{$value}\"" ; } $ attr = implode ( ' ' , $ output ) ; $ file = str_replace ( '//' , '' , "{$path}/{$file}" ) ; return sprintf ( '<link href="%s" %s>' , $ file , $ attr ) ; }
Creates an HTML style tag
24,379
private function getBlacklistPasswords ( ) : Generator { $ fh = fopen ( $ this -> file , 'rb' ) ; while ( ( $ password = fgets ( $ fh ) ) !== false ) { yield trim ( $ password ) ; } fclose ( $ fh ) ; }
Iterates over and yields each blacklisted password
24,380
public function between ( DateTime $ start , DateTime $ end ) { $ this -> start ( $ start ) -> end ( $ end ) ; return $ this ; }
Shortcut from start and end dates
24,381
public function on ( DateTime $ on ) { if ( $ on -> format ( 'His' ) !== '000000' ) { throw new RuntimeException ( 'One day events must start at midnight' ) ; } $ fin = clone $ on ; $ fin -> add ( new \ DateInterval ( 'P1D' ) ) ; $ this -> start ( $ on ) -> end ( $ fin ) -> allDay ( true ) ; return $ this ; }
One day helper Sets event to a single day
24,382
static public function secureUrl ( $ url , $ params = [ ] ) { if ( is_array ( $ url ) ) { $ url = implode ( "/" , $ url ) ; } $ headers = [ "Authorization: Bearer " . JWT :: getInternalToken ( ) ] ; $ opts = [ "http" => [ "method" => "GET" , "header" => implode ( "\r\n" , $ headers ) ] , "ssl" => array ( "verify_peer" => false , "verify_peer_name" => false , ) ] ; $ stream_context = stream_context_create ( $ opts ) ; if ( count ( $ params ) ) { $ url = $ url . "?" . http_build_query ( $ params ) ; } syslog ( LOG_INFO , __METHOD__ . " fetching: " . $ url ) ; $ content = file_get_contents ( $ url , false , $ stream_context ) ; $ result = json_decode ( $ content , JSON_OBJECT_AS_ARRAY ) ; return $ result ; }
Fetching an url secured by the Internal accesstoken . Should be using guzzle just like other Google Api stuff
24,383
static public function secureUrlCached ( $ url , $ params = [ ] ) { if ( is_array ( $ url ) ) { $ url = implode ( "/" , $ url ) ; } $ cacheKey = Cached :: keymaker ( __METHOD__ , $ url , $ params ) ; $ cached = new Cached ( $ cacheKey ) ; if ( ! $ cached -> exists ( ) ) { $ result = self :: secureUrl ( $ url , $ params ) ; syslog ( LOG_INFO , "Returned " . count ( $ result ) . " rows." ) ; $ cached -> set ( $ result ) ; } return $ cached -> get ( ) ; }
Wrapper that caches hits towards an service . Internal or otherwise .
24,384
static public function internalService ( $ application_id , $ service , $ path , $ params = [ ] ) { $ url = "https://$service-dot-$application_id.appspot.com" . $ path ; return self :: secureUrl ( $ url , $ params ) ; }
For internal service on Google App Engine . Basically just expands application and service to the correct domain on App Engine . This url is the fastest url to use internally on App engine so this method is prefered for service to service communication .
24,385
protected function checkResponseForError ( \ SimpleXMLElement $ response ) { if ( $ response -> item != null && ( ( string ) $ response -> item [ 'type' ] ) == 'error' ) { throw new MollieServerErrorException ( ( string ) $ response -> item -> message , intval ( $ response -> item -> errorcode ) ) ; } }
Check if the given response contains an error if so it will throw an exception .
24,386
public static function buildRoutes ( $ routeConfig , $ app = null ) { $ app = empty ( $ app ) ? Yii :: $ app : $ app ; $ rules = static :: collectRoutes ( $ routeConfig , $ app ) ; $ app -> urlManager -> addRules ( $ rules , $ routeConfig [ 'append' ] ) ; }
Build routes by routes config .
24,387
public static function collectRoutes ( $ routeConfig , $ app = null ) { $ app = empty ( $ app ) ? Yii :: $ app : $ app ; $ rules = [ ] ; if ( isset ( $ routeConfig [ 'urlPrefix' ] ) && $ routeConfig [ 'urlPrefix' ] !== false && is_file ( $ routeConfig [ 'fileRoutes' ] ) ) { $ routes = include ( $ routeConfig [ 'fileRoutes' ] ) ; if ( empty ( $ routes ) ) return [ ] ; switch ( $ routeConfig [ 'class' ] ) { case GroupUrlRule :: className ( ) : $ configGroupRules = [ 'rules' => $ routes , 'prefix' => $ routeConfig [ 'urlPrefix' ] , 'routePrefix' => $ routeConfig [ 'moduleUid' ] , ] ; $ rules = [ new GroupUrlRule ( $ configGroupRules ) ] ; break ; default : if ( isset ( $ routes [ 'enablePrettyUrl' ] ) ) { $ app -> urlManager -> enablePrettyUrl = $ routes [ 'enablePrettyUrl' ] ; unset ( $ routes [ 'enablePrettyUrl' ] ) ; } $ rules = $ routes ; break ; } } return $ rules ; }
Collect routes by routes config .
24,388
public static function properRule ( $ rule , $ link ) { if ( isset ( $ rule -> pattern ) ) { if ( preg_match ( $ rule -> pattern , $ link ) > 0 ) return true ; } if ( $ rule instanceof GroupUrlRule ) { foreach ( $ rule -> rules as $ nextRule ) { if ( preg_match ( $ nextRule -> pattern , $ link ) > 0 ) return true ; } } return false ; }
Check if link will recognize by route s rule .
24,389
public function setFeedType ( $ feedType , $ videoId = null , $ entry = null ) { switch ( $ feedType ) { case 'top rated' : $ this -> _url = Zend_Gdata_YouTube :: STANDARD_TOP_RATED_URI ; break ; case 'most viewed' : $ this -> _url = Zend_Gdata_YouTube :: STANDARD_MOST_VIEWED_URI ; break ; case 'recently featured' : $ this -> _url = Zend_Gdata_YouTube :: STANDARD_RECENTLY_FEATURED_URI ; break ; case 'mobile' : $ this -> _url = Zend_Gdata_YouTube :: STANDARD_WATCH_ON_MOBILE_URI ; break ; case 'related' : if ( $ videoId === null ) { require_once 'Zend/Gdata/App/InvalidArgumentException.php' ; throw new Zend_Gdata_App_InvalidArgumentException ( 'Video ID must be set for feed of type: ' . $ feedType ) ; } else { $ this -> _url = Zend_Gdata_YouTube :: VIDEO_URI . '/' . $ videoId . '/related' ; } break ; case 'responses' : if ( $ videoId === null ) { require_once 'Zend/Gdata/App/InvalidArgumentException.php' ; throw new Zend_Gdata_App_Exception ( 'Video ID must be set for feed of type: ' . $ feedType ) ; } else { $ this -> _url = Zend_Gdata_YouTube :: VIDEO_URI . '/' . $ videoId . '/responses' ; } break ; case 'comments' : if ( $ videoId === null ) { require_once 'Zend/Gdata/App/InvalidArgumentException.php' ; throw new Zend_Gdata_App_Exception ( 'Video ID must be set for feed of type: ' . $ feedType ) ; } else { $ this -> _url = Zend_Gdata_YouTube :: VIDEO_URI . '/' . $ videoId . '/comments' ; if ( $ entry !== null ) { $ this -> _url .= '/' . $ entry ; } } break ; default : require_once 'Zend/Gdata/App/Exception.php' ; throw new Zend_Gdata_App_Exception ( 'Unknown feed type' ) ; break ; } }
Sets the type of feed this query should be used to search
24,390
public function setLocation ( $ value ) { switch ( $ value ) { case null : unset ( $ this -> _params [ 'location' ] ) ; default : $ parameters = explode ( ',' , $ value ) ; if ( count ( $ parameters ) != 2 ) { require_once 'Zend/Gdata/App/InvalidArgumentException.php' ; throw new Zend_Gdata_App_InvalidArgumentException ( 'You must provide 2 coordinates to the location ' . 'URL parameter' ) ; } foreach ( $ parameters as $ param ) { $ temp = trim ( $ param ) ; if ( substr ( $ temp , - 1 ) == '!' ) { $ temp = substr ( $ temp , 0 , - 1 ) ; } if ( ! is_numeric ( $ temp ) ) { require_once 'Zend/Gdata/App/InvalidArgumentException.php' ; throw new Zend_Gdata_App_InvalidArgumentException ( 'Value provided to location parameter must' . ' be in the form of two coordinates' ) ; } } $ this -> _params [ 'location' ] = $ value ; } }
Sets the location parameter for the query
24,391
public function setTime ( $ value = null ) { switch ( $ value ) { case 'today' : $ this -> _params [ 'time' ] = 'today' ; break ; case 'this_week' : $ this -> _params [ 'time' ] = 'this_week' ; break ; case 'this_month' : $ this -> _params [ 'time' ] = 'this_month' ; break ; case 'all_time' : $ this -> _params [ 'time' ] = 'all_time' ; break ; case null : unset ( $ this -> _params [ 'time' ] ) ; default : require_once 'Zend/Gdata/App/InvalidArgumentException.php' ; throw new Zend_Gdata_App_InvalidArgumentException ( 'Unknown time value' ) ; break ; } return $ this ; }
Sets the time period over which this query should apply
24,392
public function setUploader ( $ value = null ) { switch ( $ value ) { case 'partner' : $ this -> _params [ 'uploader' ] = 'partner' ; break ; case null : unset ( $ this -> _params [ 'uploader' ] ) ; break ; default : require_once 'Zend/Gdata/App/InvalidArgumentException.php' ; throw new Zend_Gdata_App_InvalidArgumentException ( 'Unknown value for uploader' ) ; } return $ this ; }
Sets the value of the uploader parameter
24,393
public function setFormat ( $ value = null ) { if ( $ value != null ) { $ this -> _params [ 'format' ] = $ value ; } else { unset ( $ this -> _params [ 'format' ] ) ; } return $ this ; }
Sets the param to return videos of a specific format
24,394
public function setRacy ( $ value = null ) { switch ( $ value ) { case 'include' : $ this -> _params [ 'racy' ] = $ value ; break ; case 'exclude' : $ this -> _params [ 'racy' ] = $ value ; break ; case null : unset ( $ this -> _params [ 'racy' ] ) ; break ; } return $ this ; }
Sets whether or not to include racy videos in the search results
24,395
public function setSafeSearch ( $ value ) { switch ( $ value ) { case 'none' : $ this -> _params [ 'safeSearch' ] = 'none' ; break ; case 'moderate' : $ this -> _params [ 'safeSearch' ] = 'moderate' ; break ; case 'strict' : $ this -> _params [ 'safeSearch' ] = 'strict' ; break ; case null : unset ( $ this -> _params [ 'safeSearch' ] ) ; default : require_once 'Zend/Gdata/App/InvalidArgumentException.php' ; throw new Zend_Gdata_App_InvalidArgumentException ( 'The safeSearch parameter only supports the values ' . '\'none\', \'moderate\' or \'strict\'.' ) ; } }
Set the safeSearch parameter
24,396
public function getQueryString ( $ majorProtocolVersion = null , $ minorProtocolVersion = null ) { $ queryArray = array ( ) ; foreach ( $ this -> _params as $ name => $ value ) { if ( substr ( $ name , 0 , 1 ) == '_' ) { continue ; } switch ( $ name ) { case 'location-radius' : if ( $ majorProtocolVersion == 1 ) { require_once 'Zend/Gdata/App/VersionException.php' ; throw new Zend_Gdata_App_VersionException ( "The $name " . "parameter is only supported in version 2." ) ; } break ; case 'racy' : if ( $ majorProtocolVersion == 2 ) { require_once 'Zend/Gdata/App/VersionException.php' ; throw new Zend_Gdata_App_VersionException ( "The $name " . "parameter is not supported in version 2. " . "Please use 'safeSearch'." ) ; } break ; case 'safeSearch' : if ( $ majorProtocolVersion == 1 ) { require_once 'Zend/Gdata/App/VersionException.php' ; throw new Zend_Gdata_App_VersionException ( "The $name " . "parameter is only supported in version 2. " . "Please use 'racy'." ) ; } break ; case 'uploader' : if ( $ majorProtocolVersion == 1 ) { require_once 'Zend/Gdata/App/VersionException.php' ; throw new Zend_Gdata_App_VersionException ( "The $name " . "parameter is only supported in version 2." ) ; } break ; case 'vq' : if ( $ majorProtocolVersion == 2 ) { $ name = 'q' ; } break ; } $ queryArray [ ] = urlencode ( $ name ) . '=' . urlencode ( $ value ) ; } if ( count ( $ queryArray ) > 0 ) { return '?' . implode ( '&' , $ queryArray ) ; } else { return '' ; } }
Generate the query string from the URL parameters optionally modifying them based on protocol version .
24,397
public function getQueryUrl ( $ majorProtocolVersion = null , $ minorProtocolVersion = null ) { if ( isset ( $ this -> _url ) ) { $ url = $ this -> _url ; } else { $ url = Zend_Gdata_YouTube :: VIDEO_URI ; } if ( $ this -> getCategory ( ) !== null ) { $ url .= '/-/' . $ this -> getCategory ( ) ; } $ url = $ url . $ this -> getQueryString ( $ majorProtocolVersion , $ minorProtocolVersion ) ; return $ url ; }
Returns the generated full query URL optionally modifying it based on the protocol version .
24,398
public static function Gst00b ( $ uta , $ utb ) { $ gmst00 ; $ ee00b ; $ gst ; $ gmst00 = IAU :: Gmst00 ( $ uta , $ utb , $ uta , $ utb ) ; $ ee00b = IAU :: Ee00b ( $ uta , $ utb ) ; $ gst = IAU :: Anp ( $ gmst00 + $ ee00b ) ; return $ gst ; }
- - - - - - - - - - i a u G s t 0 0 b - - - - - - - - - -
24,399
public function setConfiguration ( $ config ) { if ( ! ( $ config instanceof Config ) ) $ config = new Config ( $ config ) ; $ this -> config = $ config ; }
Sets the configuration of the instance