idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
19,800 | public function insertGetId ( array $ values , $ sequence = null ) { $ result = $ this -> collection -> insertOne ( $ values ) ; if ( 1 == ( int ) $ result -> isAcknowledged ( ) ) { if ( is_null ( $ sequence ) ) { $ sequence = '_id' ; } return $ sequence == '_id' ? trim ( $ result -> getInsertedId ( ) ) : $ values [ $ sequence ] ; } return null ; } | Insert documet and return ID . |
19,801 | public function delete ( $ id = null ) { if ( ! is_null ( $ id ) ) { $ this -> where ( '_id' , '=' , $ id ) ; } $ wheres = $ this -> compileWheres ( ) ; $ result = $ this -> collection -> deleteMany ( $ wheres ) ; if ( 1 == ( int ) $ result -> isAcknowledged ( ) ) { return $ result -> getDeletedCount ( ) ; } return 0 ; } | Delete documents . |
19,802 | protected function getFreshNormal ( $ wheres ) { $ columns = [ ] ; foreach ( $ this -> columns as $ column ) { $ columns [ $ column ] = true ; } if ( $ this -> projections ) { $ columns = array_merge ( $ columns , $ this -> projections ) ; } $ options = [ ] ; if ( $ this -> orders ) { $ options [ 'sort' ] = $ this -> compileOrders ( $ this -> orders ) ; } if ( $ this -> offset ) { $ options [ 'skip' ] = $ this -> offset ; } if ( $ this -> limit ) { $ options [ 'limit' ] = $ this -> limit ; } if ( $ columns ) { $ options [ 'projection' ] = $ columns ; } $ options [ 'typeMap' ] = [ 'root' => 'array' , 'document' => 'array' ] ; if ( count ( $ this -> options ) ) { $ options = array_merge ( $ options , $ this -> options ) ; } $ cursor = $ this -> collection -> find ( $ wheres , $ options ) ; $ results = iterator_to_array ( $ cursor , false ) ; return $ results ; } | Fetch Normal . |
19,803 | public static function convertKey ( $ id ) { if ( is_string ( $ id ) && strlen ( $ id ) === 24 && ctype_xdigit ( $ id ) ) { return new ObjectID ( $ id ) ; } return $ id ; } | Convert a key to ObjectID if needed . |
19,804 | public function store ( $ code , $ label , $ country_id = null , $ country_code = null ) { $ fields = [ ] ; $ fields [ 'code' ] = $ code ; $ fields [ 'label' ] = $ label ; if ( ! is_null ( $ country_id ) ) $ fields [ 'country_id' ] = $ country_id ; if ( ! is_null ( $ country_code ) ) $ fields [ 'country_code' ] = $ country_code ; return $ this -> _post ( $ fields ) ; } | Store Mobile Carrier |
19,805 | protected static function registerModelEvent ( $ event , $ callback ) { $ event = self :: makeModelEventName ( $ event ) ; event ( ) -> listen ( $ event , $ callback ) ; } | Register evento model . |
19,806 | private static function singleCall ( array $ request , Parameters $ parameters_object ) { if ( ! isset ( $ request [ 0 ] ) || ! isset ( $ request [ 1 ] ) ) { return self :: packError ( - 32600 , $ parameters_object -> errors ( ) -> get ( - 32600 ) ) ; } if ( $ request [ 0 ] == 'system.multicall' ) { return self :: packError ( - 31001 , $ parameters_object -> errors ( ) -> get ( - 31001 ) ) ; } $ payload = array ( $ request [ 0 ] , $ request [ 1 ] ) ; try { return XmlProcessor :: process ( $ payload , $ parameters_object , $ parameters_object -> logger ( ) ) ; } catch ( RpcException $ re ) { return self :: packError ( $ re -> getCode ( ) , $ re -> getMessage ( ) ) ; } catch ( Exception $ e ) { return self :: packError ( - 32500 , $ re -> getMessage ( ) ) ; } } | Perform a single call |
19,807 | public function get ( Request $ request ) { $ userEntity = $ request -> attributes -> get ( 'user' ) ; if ( $ userEntity === null ) { $ userEntity = $ this -> getUser ( ) ; } elseif ( $ userEntity === false ) { return $ this -> createNotFoundResponse ( ) ; } return $ this -> userArrayWithoutPassword ( $ userEntity ) ; } | Return a user entity |
19,808 | public function put ( Request $ request ) { $ user = $ this -> getUser ( ) ; $ userValidationCopy = clone $ user ; $ content = $ this -> getContentAsArray ( $ request ) ; $ errors = $ this -> userValidator -> validate ( $ content , $ user ) ; if ( count ( $ errors ) > 0 ) { return $ this -> createConstraintViolationResponse ( $ errors ) ; } $ userValidationCopy -> exchangeArray ( $ content ? : [ ] ) -> getArrayCopy ( ) ; try { $ user = $ this -> userService -> update ( $ user , $ this -> getContentAsArray ( $ request ) ) ; } catch ( OutOfBoundsException $ e ) { return $ this -> createEmailNotUniqueResponse ( ) ; } return $ this -> userArrayWithoutPassword ( $ user ) ; } | Edit a user ; requires the user to be logged in and the current password provided |
19,809 | protected function getOutputHandler ( ServerRequestInterface $ request , ResponseInterface $ response , \ Throwable $ e ) : Run { $ whoops = new Run ( ) ; $ whoops -> writeToOutput ( false ) ; switch ( $ this -> determineOutputType ( ) ) { case self :: TYPE_JSON : $ whoops -> pushHandler ( [ $ this , 'renderJson' ] ) ; break ; case self :: TYPE_XML : $ whoops -> pushHandler ( [ $ this , 'renderXML' ] ) ; break ; case self :: TYPE_PLAIN : $ whoops -> pushHandler ( [ $ this , 'renderPlainText' ] ) ; break ; default : $ whoops -> pushHandler ( [ $ this , 'renderHtml' ] ) ; } return $ whoops ; } | Parameter just for reference |
19,810 | protected function generateOutputHandler ( ServerRequestInterface $ request , ResponseInterface $ response , \ Throwable $ e ) : ResponseInterface { $ contentType = $ this -> getContentType ( ) ; if ( ! $ contentType ) { $ contentType = $ response -> getHeaderLine ( 'Content-Type' ) ? : ( $ request -> getHeaderLine ( 'Content-Type' ) ? : static :: DEFAULT_CONTENT_TYPE ) ; $ this -> setContentType ( $ contentType ) ; } $ this -> cleanOutputBuffer ( ) ; $ body = new RequestBody ( ) ; $ handler = $ this -> getOutputHandler ( $ request , $ response , $ e ) ; $ handler -> allowQuit ( false ) ; $ this -> logThrowable ( $ e ) ; $ body -> write ( $ handler -> handleException ( $ e ) ) ; return $ response -> withBody ( $ body ) -> withHeader ( 'Content-Type' , $ contentType ) ; } | Generate Output Handler For Response |
19,811 | public function replyAction ( ) { $ questionInteract = $ this -> get ( 'qcm_core.question.interact' ) ; if ( ! $ questionInteract -> isStarted ( ) ) { $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'danger' , 'qcm_public.questionnaire.not_started' ) ; return $ this -> redirect ( $ this -> generateUrl ( 'qcm_public_homepage' ) ) ; } $ question = $ questionInteract -> getQuestion ( ) ; $ formType = $ this -> get ( 'qcm_core.form.type.reply' ) ; $ form = $ this -> createForm ( $ formType , $ questionInteract -> getUserConfiguration ( ) ) ; return $ this -> render ( 'QcmPublicBundle:Question:reply.html.twig' , array ( 'question' => $ question , 'form' => $ form -> createView ( ) ) ) ; } | Question reply action |
19,812 | public function prevQuexstionAction ( ) { $ questionInteract = $ this -> get ( 'qcm_core.question.interact' ) ; $ questionInteract -> getPrevQuestion ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'qcm_public_question_reply' ) ) ; } | Get previous question |
19,813 | private function generateLogRequestData ( RequestInterface $ request ) { return array ( 'class' => get_class ( $ request ) , 'method' => $ request -> getMethod ( ) , 'index' => $ request -> getIndex ( ) , 'type' => $ request -> getType ( ) , 'action' => $ request -> getAction ( ) , 'response_class' => $ request -> getSupportedClass ( ) , 'body' => $ request -> getBody ( ) ) ; } | generates an array with all request information in it . |
19,814 | public function setType ( $ type = null ) { if ( is_array ( $ type ) ) { $ detected = 0 ; foreach ( $ type as $ value ) { if ( is_int ( $ value ) ) { $ detected += $ value ; } elseif ( in_array ( $ value , $ this -> constants ) ) { $ detected += array_search ( $ value , $ this -> constants ) ; } } $ type = $ detected ; } elseif ( is_string ( $ type ) && in_array ( $ type , $ this -> constants ) ) { $ type = array_search ( $ type , $ this -> constants ) ; } if ( ! is_int ( $ type ) || ( $ type < 0 ) || ( $ type > self :: TYPE_ALL ) ) { throw new Exception \ InvalidArgumentException ( sprintf ( 'Unknown type value "%s" (%s)' , $ type , gettype ( $ type ) ) ) ; } $ this -> options [ 'type' ] = $ type ; return $ this ; } | Set boolean types |
19,815 | public function export ( $ schemaName = null ) { $ dump = [ ] ; $ sql = "SELECT type, name, sql FROM sqlite_master WHERE type != 'index' AND name != 'sqlite_sequence' ORDER BY type" ; $ rows = $ this -> connection -> selectAll ( $ sql ) ; foreach ( $ rows as $ row ) { $ dump [ ] = preg_replace ( '/\v/' , ' ' , $ row [ 'sql' ] ) ; } return implode ( ";\n\n" , $ dump ) . ";\n" ; } | Very basic exporter . It takes the sql column from sqlite_master and since there s not a standarized syntax by taking SQL that way it tries to turn queries into single - line queries by removing all line breaks so it ll be easier to import the queries . |
19,816 | public static function resolve ( $ oldUrl ) { $ url = new Url ( $ oldUrl ) ; foreach ( static :: $ urls as $ method => $ matches ) { if ( $ url -> match ( $ matches ) ) { return static :: $ method ( $ url ) ; } } return $ oldUrl ; } | Resolve the url redirection |
19,817 | protected static function hashBang ( Url $ url ) { if ( ( $ path = preg_replace ( '|^(/?!)|' , '' , $ url -> getFragment ( ) ) ) ) { return $ url -> withPath ( $ url -> getPath ( ) . $ path ) -> getUrl ( ) ; } return $ url -> getUrl ( ) ; } | Resolve an url with hashbang |
19,818 | public function append ( $ href , $ rel = null , $ type = null , $ media = null ) { self :: $ linkList -> append ( array ( $ sHref , $ sRel , $ sType , $ sMedia ) ) ; return $ this ; } | Append a link |
19,819 | public function prepend ( $ href , $ rel = null , $ type = null , $ media = null ) { self :: $ linkList -> prepend ( array ( $ href , $ rel , $ type , $ media ) ) ; return $ this ; } | Prepend a link |
19,820 | public function render ( ) { $ htmlContent = '' ; foreach ( self :: $ linkList -> toArray ( ) as $ link ) { $ htmlContent .= '<link href="' . $ link [ 0 ] . '"' ; if ( ! empty ( $ link [ 1 ] ) ) { $ htmlContent .= ' rel="' . $ link [ 1 ] . '"' ; } if ( ! empty ( $ link [ 2 ] ) ) { $ htmlContent .= ' type="' . $ link [ 2 ] . '"' ; } if ( ! empty ( $ link [ 3 ] ) ) { $ htmlContent .= ' media="' . $ link [ 3 ] . '"' ; } $ htmlContent .= '>' . PHP_EOL ; } return $ htmlContent ; } | Return HTML code for initialize all link in link list |
19,821 | public function filterByAthleteLabel ( $ athleteLabel = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ athleteLabel ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ athleteLabel ) ) { $ athleteLabel = str_replace ( '*' , '%' , $ athleteLabel ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( SportTableMap :: COL_ATHLETE_LABEL , $ athleteLabel , $ comparison ) ; } | Filter the query on the athlete_label column |
19,822 | public function filterByObjectSlug ( $ objectSlug = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ objectSlug ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ objectSlug ) ) { $ objectSlug = str_replace ( '*' , '%' , $ objectSlug ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( SportTableMap :: COL_OBJECT_SLUG , $ objectSlug , $ comparison ) ; } | Filter the query on the object_slug column |
19,823 | public function filterByObjectLabel ( $ objectLabel = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ objectLabel ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ objectLabel ) ) { $ objectLabel = str_replace ( '*' , '%' , $ objectLabel ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( SportTableMap :: COL_OBJECT_LABEL , $ objectLabel , $ comparison ) ; } | Filter the query on the object_label column |
19,824 | public function filterByObjectPluralLabel ( $ objectPluralLabel = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ objectPluralLabel ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ objectPluralLabel ) ) { $ objectPluralLabel = str_replace ( '*' , '%' , $ objectPluralLabel ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( SportTableMap :: COL_OBJECT_PLURAL_LABEL , $ objectPluralLabel , $ comparison ) ; } | Filter the query on the object_plural_label column |
19,825 | public function filterBySkillSlug ( $ skillSlug = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ skillSlug ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ skillSlug ) ) { $ skillSlug = str_replace ( '*' , '%' , $ skillSlug ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( SportTableMap :: COL_SKILL_SLUG , $ skillSlug , $ comparison ) ; } | Filter the query on the skill_slug column |
19,826 | public function filterBySkillLabel ( $ skillLabel = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ skillLabel ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ skillLabel ) ) { $ skillLabel = str_replace ( '*' , '%' , $ skillLabel ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( SportTableMap :: COL_SKILL_LABEL , $ skillLabel , $ comparison ) ; } | Filter the query on the skill_label column |
19,827 | public function filterBySkillPluralLabel ( $ skillPluralLabel = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ skillPluralLabel ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ skillPluralLabel ) ) { $ skillPluralLabel = str_replace ( '*' , '%' , $ skillPluralLabel ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( SportTableMap :: COL_SKILL_PLURAL_LABEL , $ skillPluralLabel , $ comparison ) ; } | Filter the query on the skill_plural_label column |
19,828 | public function filterBySkillPictureUrl ( $ skillPictureUrl = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ skillPictureUrl ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ skillPictureUrl ) ) { $ skillPictureUrl = str_replace ( '*' , '%' , $ skillPictureUrl ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( SportTableMap :: COL_SKILL_PICTURE_URL , $ skillPictureUrl , $ comparison ) ; } | Filter the query on the skill_picture_url column |
19,829 | public function filterByGroupSlug ( $ groupSlug = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ groupSlug ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ groupSlug ) ) { $ groupSlug = str_replace ( '*' , '%' , $ groupSlug ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( SportTableMap :: COL_GROUP_SLUG , $ groupSlug , $ comparison ) ; } | Filter the query on the group_slug column |
19,830 | public function filterByGroupLabel ( $ groupLabel = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ groupLabel ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ groupLabel ) ) { $ groupLabel = str_replace ( '*' , '%' , $ groupLabel ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( SportTableMap :: COL_GROUP_LABEL , $ groupLabel , $ comparison ) ; } | Filter the query on the group_label column |
19,831 | public function filterByGroupPluralLabel ( $ groupPluralLabel = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ groupPluralLabel ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ groupPluralLabel ) ) { $ groupPluralLabel = str_replace ( '*' , '%' , $ groupPluralLabel ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( SportTableMap :: COL_GROUP_PLURAL_LABEL , $ groupPluralLabel , $ comparison ) ; } | Filter the query on the group_plural_label column |
19,832 | public function filterByTransitionLabel ( $ transitionLabel = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ transitionLabel ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ transitionLabel ) ) { $ transitionLabel = str_replace ( '*' , '%' , $ transitionLabel ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( SportTableMap :: COL_TRANSITION_LABEL , $ transitionLabel , $ comparison ) ; } | Filter the query on the transition_label column |
19,833 | public function filterByTransitionPluralLabel ( $ transitionPluralLabel = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ transitionPluralLabel ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ transitionPluralLabel ) ) { $ transitionPluralLabel = str_replace ( '*' , '%' , $ transitionPluralLabel ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( SportTableMap :: COL_TRANSITION_PLURAL_LABEL , $ transitionPluralLabel , $ comparison ) ; } | Filter the query on the transition_plural_label column |
19,834 | public function filterByTransitionsSlug ( $ transitionsSlug = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ transitionsSlug ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ transitionsSlug ) ) { $ transitionsSlug = str_replace ( '*' , '%' , $ transitionsSlug ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( SportTableMap :: COL_TRANSITIONS_SLUG , $ transitionsSlug , $ comparison ) ; } | Filter the query on the transitions_slug column |
19,835 | public function filterByPositionSlug ( $ positionSlug = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ positionSlug ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ positionSlug ) ) { $ positionSlug = str_replace ( '*' , '%' , $ positionSlug ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( SportTableMap :: COL_POSITION_SLUG , $ positionSlug , $ comparison ) ; } | Filter the query on the position_slug column |
19,836 | public function filterByPositionLabel ( $ positionLabel = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ positionLabel ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ positionLabel ) ) { $ positionLabel = str_replace ( '*' , '%' , $ positionLabel ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( SportTableMap :: COL_POSITION_LABEL , $ positionLabel , $ comparison ) ; } | Filter the query on the position_label column |
19,837 | public function filterByFeatureComposition ( $ featureComposition = null , $ comparison = null ) { if ( is_string ( $ featureComposition ) ) { $ featureComposition = in_array ( strtolower ( $ featureComposition ) , array ( 'false' , 'off' , '-' , 'no' , 'n' , '0' , '' ) ) ? false : true ; } return $ this -> addUsingAlias ( SportTableMap :: COL_FEATURE_COMPOSITION , $ featureComposition , $ comparison ) ; } | Filter the query on the feature_composition column |
19,838 | public function useObjectQuery ( $ relationAlias = null , $ joinType = Criteria :: INNER_JOIN ) { return $ this -> joinObject ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'Object' , '\gossi\trixionary\model\ObjectQuery' ) ; } | Use the Object relation Object object |
19,839 | public function usePositionQuery ( $ relationAlias = null , $ joinType = Criteria :: INNER_JOIN ) { return $ this -> joinPosition ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'Position' , '\gossi\trixionary\model\PositionQuery' ) ; } | Use the Position relation Position object |
19,840 | public function useGroupQuery ( $ relationAlias = null , $ joinType = Criteria :: INNER_JOIN ) { return $ this -> joinGroup ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'Group' , '\gossi\trixionary\model\GroupQuery' ) ; } | Use the Group relation Group object |
19,841 | public function getToken ( ) : string { if ( ( $ this -> token === null ) || ( $ this -> token -> isExpired ( ) ) ) { $ jwtBuilder = new Builder ( ) ; $ jwtBuilder -> set ( 'iss' , $ this -> handlerPublicKey ) ; $ jwtBuilder -> set ( 'sub' , $ this -> credentialPublicKey ) ; $ this -> token = $ jwtBuilder -> sign ( new Sha256 ( ) , $ this -> handlerPrivateKey ) -> getToken ( ) ; } return ( string ) $ this -> token ; } | Generates the credential token and returns it . |
19,842 | public function affectChunks ( callable $ function , ... $ delimiters ) { $ delimiter_string = "" ; $ replace_callback = function ( $ matches ) use ( $ function ) { $ callback_string = $ function ( $ matches [ 0 ] ) ; return $ callback_string ; } ; foreach ( $ delimiters as $ delimiter ) { $ delimiter_string .= preg_quote ( $ delimiter , "/" ) ; } $ pattern = "/[^{$delimiter_string}]+/" ; $ affected_string = preg_replace_callback ( $ pattern , $ replace_callback , $ this -> string ) ; return $ affected_string ; } | Given a delimited string returns a copy of the string with chunks defined by the delimiter affected by a given function . |
19,843 | public function startsWith ( $ string ) { $ pattern = "/^" . preg_quote ( $ string , "/" ) . "/" ; $ starts_with_string = preg_match ( $ pattern , $ this -> string ) ; return ( bool ) $ starts_with_string ; } | Determines whether the string starts with a given string . |
19,844 | public function collapseStartingRepetition ( $ string ) { $ matches = array ( ) ; $ pattern = "/^[" . preg_quote ( $ string , "/" ) . "]+(?P<remainder>.*)/" ; $ starts_with_string = preg_match ( $ pattern , $ this -> string , $ matches ) ; if ( $ starts_with_string ) { $ collapsed_string = $ string . $ matches [ "remainder" ] ; return $ collapsed_string ; } else { return $ this -> string ; } } | Given a string collapses any repetition at the start of the string into a single instance of the given string . If the given string does not exist at the start of the string returns an unmodified string . |
19,845 | public function uninstall ( ) { $ this -> deactivate ( ) ; app ( 'migration' ) -> revert ( $ this -> getPath ( ) . '/migrations' , $ this -> getPackage ( ) ) ; return $ this ; } | uninstall the extension |
19,846 | protected function doBind ( ) { $ parsed = self :: $ parser -> parse ( $ this -> statement ) ; $ index = 0 ; $ params = $ this -> getParameters ( ) ; $ this -> walk ( $ parsed , $ index , $ params ) ; return self :: $ creator -> create ( $ parsed ) ; } | Binds parameters into statement to create a new statement ready to execute |
19,847 | static public function getBounds ( DateTime $ date , $ granularity = UDATE_GRANULARITY_SECOND ) { $ bounds = array ( clone $ date , clone $ date ) ; switch ( $ granularity ) { case UDATE_GRANULARITY_SECOND : return array ( $ date , $ date ) ; case UDATE_GRANULARITY_MINUTE : $ bounds [ 0 ] -> setDate ( $ date -> get , $ month , $ day ) ; return array ( DateTime :: createFromFormat ( UDATE_PHP_DATETIME , $ date -> format ( "Y-m-d H:i:00" ) ) , DateTime :: createFromFormat ( UDATE_PHP_DATETIME , $ date -> format ( "Y-m-d H:i:59" ) ) , ) ; case UDATE_GRANULARITY_HOUR : return array ( DateTime :: createFromFormat ( UDATE_PHP_DATETIME , $ date -> format ( "Y-m-d H:00:00" ) ) , DateTime :: createFromFormat ( UDATE_PHP_DATETIME , $ date -> format ( "Y-m-d H:59:59" ) ) , ) ; case UDATE_GRANULARITY_DAY : return array ( DateTime :: createFromFormat ( UDATE_PHP_DATETIME , $ date -> format ( "Y-m-d 00:00:00" ) ) , DateTime :: createFromFormat ( UDATE_PHP_DATETIME , $ date -> format ( "Y-m-d 23:59:59" ) ) , ) ; case UDATE_GRANULARITY_MONTH : return array ( DateTime :: createFromFormat ( UDATE_PHP_DATETIME , $ date -> format ( "Y-m-01 00:00:00" ) ) , DateTime :: createFromFormat ( UDATE_PHP_DATETIME , $ date -> format ( "Y-m-31 23:59:59" ) ) , ) ; case UDATE_GRANULARITY_YEAR : return array ( DateTime :: createFromFormat ( UDATE_PHP_DATETIME , $ date -> format ( "Y-01-01 00:00:00" ) ) , DateTime :: createFromFormat ( UDATE_PHP_DATETIME , $ date -> format ( "Y-12-31 23:59:59" ) ) , ) ; default : return null ; } } | Build SQL formula |
19,848 | private function assertUserIsLoggedIn ( ) { $ token = $ this -> securityContext -> getToken ( ) ; $ isAuthenticated = $ token !== null && $ token -> isAuthenticated ( ) && $ token -> getUser ( ) instanceof User && $ token -> getUser ( ) -> isCredentialsNonExpired ( ) ; if ( ! $ isAuthenticated ) { throw new AccessDeniedException ( ) ; } } | Asserts that a user is logged in |
19,849 | private function updateClientAccessToken ( ) { $ user = $ this -> securityContext -> getToken ( ) -> getUser ( ) ; $ this -> client -> updateAccessToken ( $ user -> getAccessToken ( ) ) ; } | Updates the access token of the HTTP client with the access token of the current user |
19,850 | public function validateNumeric ( ) { $ val = $ this -> getValue ( ) + 0 ; return $ val >= $ this -> getArg ( 0 ) && $ val <= $ this -> getArg ( 1 ) ; } | Validate number as is it numeric |
19,851 | public function validateString ( ) { $ len = function_exists ( 'mb_strlen' ) ? mb_strlen ( $ this -> getValue ( ) ) : strlen ( $ this -> getValue ( ) ) ; return $ len >= $ this -> getArg ( 0 ) && $ len <= $ this -> getArg ( 1 ) ; } | Validate string by min length |
19,852 | public function getMessage ( ) { return sprintf ( 'The field `%s` length should be between %d and %d. (%d given) !' , $ this -> inputName , $ this -> getArg ( 0 ) , $ this -> getArg ( 1 ) , $ this -> getValue ( ) ) ; } | Get error message in case of fail |
19,853 | private function make_slug ( $ file , & $ tmpl ) { return $ this -> is_index ( $ file [ 'file' ] ) ? '' : $ this -> slugify -> slugify ( $ file [ 'title' ] ) ; } | Make the page slug . |
19,854 | private function make_data ( $ file ) { if ( ! array_key_exists ( 'template' , $ file ) ) { throw new Exception ( 'x> Current page: ' . $ file [ 'title' ] . ' does not have a template.' ) ; } $ t = Application :: templates ( ) -> template ( $ file [ 'template' ] ) ; $ tmpl = $ file ; $ tmpl [ 'slug' ] = $ this -> make_slug ( $ file , $ tmpl ) ; $ data_folder = Application :: data_folder ( ) ; $ template_name = $ data_folder . '/templates/' . $ t ; $ content_template = $ data_folder . '/' . $ file [ 'content' ] ; $ render_content_with = Application :: renders ( ) -> select ( $ content_template ) ; $ render_with = Application :: renders ( ) -> select ( $ template_name ) ; $ tmpl [ 'html' ] = $ render_with -> render ( $ template_name , [ 'content' => $ render_content_with -> render ( $ content_template , [ 'post' => $ file , ] ) , 'post' => $ file , ] ) ; if ( $ this -> is_index ( $ file [ 'file' ] ) ) { $ this -> log_current_page ( 'index' , '' ) ; } else { $ this -> log_current_page ( $ file [ 'title' ] , $ tmpl [ 'slug' ] ) ; } return $ tmpl ; } | Format a file to be rendered . |
19,855 | public function getScheme ( ) { if ( $ this -> _schema === null ) { $ this -> _schema = $ this -> isSecureConnection ( ) ? 'https' : 'http' ; } return $ this -> _schema ; } | Returns schema . |
19,856 | public function getAbsoluteUrl ( $ strip = true ) { $ url = $ this -> getHostInfo ( ) . $ this -> getUrl ( ) ; return $ strip === true ? strip_tags ( $ url ) : $ url ; } | Returns the currently requested absolute URL . |
19,857 | public function getUrlWithoutArgs ( ) { $ url = $ this -> getUrl ( ) ; if ( ( $ pos = strpos ( $ url , '?' ) ) !== false ) { $ url = substr ( $ url , 0 , $ pos ) ; } return $ url ; } | Returns path . |
19,858 | public function getPort ( ) { if ( $ this -> _port === null ) { $ this -> _port = ! $ this -> isSecureConnection ( ) && isset ( $ _SERVER [ 'SERVER_PORT' ] ) ? ( int ) $ _SERVER [ 'SERVER_PORT' ] : 80 ; } return $ this -> _port ; } | Returns the port to use for insecure requests . |
19,859 | public function setPort ( $ port ) { if ( $ port != $ this -> _port ) { $ this -> _port = ( int ) $ port ; $ this -> _hostInfo = null ; } return $ this ; } | Sets the port to use for insecure requests . This setter is provided in case a custom port is necessary for certain server configurations . |
19,860 | public function getSecurePort ( ) { if ( $ this -> _securePort === null ) { $ this -> _securePort = $ this -> isSecureConnection ( ) && isset ( $ _SERVER [ 'SERVER_PORT' ] ) ? ( int ) $ _SERVER [ 'SERVER_PORT' ] : 443 ; } return $ this -> _securePort ; } | Returns the port to use for secure requests . |
19,861 | public function getQueryString ( ) { if ( isset ( $ this -> _queryString ) ) { return $ this -> _queryString ; } return $ this -> _queryString = isset ( $ _SERVER [ 'QUERY_STRING' ] ) ? $ _SERVER [ 'QUERY_STRING' ] : '' ; } | Returns part of the request URL that is after the question mark . |
19,862 | public function getContentType ( ) { if ( isset ( $ this -> _contentType ) ) { return $ this -> _contentType ; } if ( isset ( $ _SERVER [ "CONTENT_TYPE" ] ) ) { return $ this -> _contentType = $ _SERVER [ "CONTENT_TYPE" ] ; } elseif ( isset ( $ _SERVER [ "HTTP_CONTENT_TYPE" ] ) ) { return $ this -> _contentType = $ _SERVER [ "HTTP_CONTENT_TYPE" ] ; } return null ; } | Returns request content - type . |
19,863 | public function isSelfDomain ( $ throw = false ) { if ( ! $ domains = $ this -> allowDomains ) { return true ; } if ( ! in_array ( strtolower ( $ _SERVER [ 'SERVER_NAME' ] ) , $ domains , true ) || ! in_array ( strtolower ( $ _SERVER [ 'HTTP_HOST' ] ) , $ domains , true ) ) { if ( $ throw === true ) { throw new RequestException ( "Invalid domain: {$_SERVER['HTTP_HOST']}" ) ; } else { if ( class_exists ( '\rock\log\Log' ) ) { $ message = BaseException :: convertExceptionToString ( new RequestException ( "Invalid domain: {$_SERVER['HTTP_HOST']}" ) ) ; Log :: err ( $ message ) ; } } return false ; } return true ; } | Is self domain . |
19,864 | protected function resolveRequestUri ( ) { if ( isset ( $ _SERVER [ 'HTTP_X_REWRITE_URL' ] ) ) { $ requestUri = $ _SERVER [ 'HTTP_X_REWRITE_URL' ] ; } elseif ( isset ( $ _SERVER [ 'REQUEST_URI' ] ) ) { $ requestUri = $ _SERVER [ 'REQUEST_URI' ] ; if ( $ requestUri !== '' && $ requestUri [ 0 ] !== '/' ) { $ requestUri = preg_replace ( '/^(http|https):\/\/[^\/]+/i' , '' , $ requestUri ) ; } } elseif ( isset ( $ _SERVER [ 'ORIG_PATH_INFO' ] ) ) { $ requestUri = $ _SERVER [ 'ORIG_PATH_INFO' ] ; if ( $ query = $ this -> getQueryString ( ) ) { $ requestUri .= '?' . $ query ; } } else { throw new RequestException ( 'Unable to determine the request URI.' ) ; } return $ requestUri ; } | Resolves the request URI portion for the currently requested URL . |
19,865 | public function getReferrer ( ) { if ( isset ( $ this -> _referrer ) ) { return $ this -> _referrer ; } return $ this -> _referrer = isset ( $ _SERVER [ 'HTTP_REFERER' ] ) ? $ _SERVER [ 'HTTP_REFERER' ] : null ; } | Returns the URL referrer null if not present . |
19,866 | public function getUserAgent ( ) { if ( isset ( $ this -> _userAgent ) ) { return $ this -> _userAgent ; } return $ this -> _userAgent = isset ( $ _SERVER [ 'HTTP_USER_AGENT' ] ) ? $ _SERVER [ 'HTTP_USER_AGENT' ] : null ; } | Returns the user agent null if not present . |
19,867 | public function getUserHost ( ) { if ( isset ( $ this -> _userHost ) ) { return $ this -> _userHost ; } return $ this -> _userHost = isset ( $ _SERVER [ 'REMOTE_HOST' ] ) ? $ _SERVER [ 'REMOTE_HOST' ] : null ; } | Returns the user host name null if it cannot be determined . |
19,868 | public function isPjax ( ) { if ( isset ( $ this -> _isPjax ) ) { return $ this -> _isPjax ; } return $ this -> _isPjax = $ this -> isAjax ( ) && ! empty ( $ _SERVER [ 'HTTP_X_PJAX' ] ) ; } | Returns whether this is a PJAX request . |
19,869 | public function isCORS ( ) { if ( isset ( $ this -> _isCORS ) ) { return $ this -> _isCORS ; } return $ this -> _isCORS = ! empty ( $ _SERVER [ 'HTTP_ORIGIN' ] ) ; } | Returns whether this is a CORS request . |
19,870 | protected function getInternal ( $ name = null , $ default = null , Sanitize $ sanitize = null ) { return $ this -> sanitizeValue ( $ this -> rawGetInternal ( $ name , $ default ) , $ sanitize ) ; } | Sanitize GET request - value . |
19,871 | protected function postInternal ( $ name = null , $ default = null , Sanitize $ sanitize = null ) { return $ this -> sanitizeValue ( $ this -> rawPostInternal ( $ name , $ default ) , $ sanitize ) ; } | Sanitize POST request - value . |
19,872 | protected function sanitizeValue ( $ input , Sanitize $ sanitize = null ) { if ( ! isset ( $ sanitize ) ) { $ sanitize = $ this -> sanitize ? : Sanitize :: removeTags ( ) -> trim ( ) -> toType ( ) ; } if ( is_array ( $ input ) ) { $ rawRule = $ sanitize -> getRawRules ( ) ; $ rawRule = current ( $ rawRule ) ; if ( $ rawRule instanceof Attributes ) { return $ sanitize -> sanitize ( $ input ) ; } return Sanitize :: attributes ( $ sanitize ) -> sanitize ( $ input ) ; } return $ sanitize -> sanitize ( $ input ) ; } | Sanitize request - value . |
19,873 | private function seed ( ) { foreach ( $ this -> input as $ key => $ value ) { if ( ! $ this -> call ( $ this -> before , $ value , $ key ) ) { return ; } yield $ key => $ value ; if ( ! $ this -> call ( $ this -> after , $ value , $ key ) ) { return ; } } } | Crea un generador |
19,874 | protected function toText ( $ fieldName ) { $ fieldName = $ this -> camelize ( $ fieldName ) ; $ fieldName = str_replace ( '_' , ' ' , $ fieldName ) ; return ucfirst ( $ fieldName ) ; } | Transform a fieldName to a text . |
19,875 | protected function getTrans ( $ filename ) { if ( is_file ( $ filename ) ) { $ trans = Yaml :: parse ( file_get_contents ( $ filename ) ) ; } else { $ trans = array ( ) ; } $ keys = array ( 'breadcrumb' , 'list' , 'filter' , 'show' , 'form' ) ; foreach ( $ keys as $ key ) { if ( ! array_key_exists ( $ key , $ trans ) ) { $ trans [ $ key ] = array ( ) ; } } return $ trans ; } | Load translation file . |
19,876 | public function register ( ) { $ this -> app -> singleton ( 'hipchat' , function ( $ app ) { return new Client ( config ( 'hipchat.api_token' ) , config ( 'hipchat.server_url' ) ) ; } ) ; $ this -> app -> alias ( Bestit \ HipChat \ Facade \ HipChat :: class , 'HipChat' ) ; } | Register the service provider and alias |
19,877 | public static function backtrace ( $ trace = null ) { $ trace or $ trace = debug_backtrace ( ) ; if ( \ Fuel :: $ is_cli ) { $ str = '' ; foreach ( $ trace as $ i => $ frame ) { $ line = "#$i\t" ; if ( ! isset ( $ frame [ 'file' ] ) ) { $ line .= "[internal function]" ; } else { $ line .= $ frame [ 'file' ] . ":" . $ frame [ 'line' ] ; } $ line .= "\t" ; if ( isset ( $ frame [ 'function' ] ) ) { if ( isset ( $ frame [ 'class' ] ) ) { $ line .= $ frame [ 'class' ] . '::' ; } $ line .= $ frame [ 'function' ] . "()" ; } $ str .= $ line . "\n" ; } return $ str ; } else { return static :: dump ( $ trace ) ; } } | Output the call stack from here or the supplied one . |
19,878 | public function index ( $ identifiers = null ) { $ parents = func_get_args ( ) ; if ( $ this -> failsSecurity ( ) ) { return $ this -> responseDenied ( ) ; } if ( $ this -> failsParentMatch ( $ parents ) ) { return $ this -> responseNotFound ( ) ; } $ entities = $ parents ? $ this -> resource -> allByParent ( end ( $ parents ) ) : $ this -> resource -> all ( ) ; return $ this -> response ( $ entities , 200 ) ; } | Shows all of a resource . |
19,879 | public function update ( $ identifiers ) { $ parents = func_get_args ( ) ; $ id = array_pop ( $ parents ) ; $ entity = $ parents ? $ this -> resource -> singleByParent ( end ( $ parents ) , $ id ) : $ this -> resource -> single ( $ id ) ; if ( $ this -> failsSecurity ( $ entity ) ) { return $ this -> responseDenied ( ) ; } if ( ! $ entity || $ this -> failsParentMatch ( $ parents ) ) { return $ this -> responseNotFound ( ) ; } $ input = $ this -> getInput ( ) ; if ( $ this -> failsValidation ( $ input ) ) { return $ this -> responseBadInput ( ) ; } $ this -> resource -> update ( $ id , $ input ) ; return $ this -> response ( null , 204 ) ; } | Updates and existing resource . |
19,880 | public function delete ( $ identifiers ) { $ parents = func_get_args ( ) ; $ id = array_pop ( $ parents ) ; $ entity = $ parents ? $ this -> resource -> singleByParent ( end ( $ parents ) , $ id ) : $ this -> resource -> single ( $ id ) ; if ( $ this -> failsSecurity ( $ entity ) ) { return $ this -> responseDenied ( ) ; } if ( ! $ entity || $ this -> failsParentMatch ( $ parents ) ) { return $ this -> responseNotFound ( ) ; } $ this -> resource -> delete ( $ id ) ; return $ this -> response ( null , 204 ) ; } | Deletes an existing resource . |
19,881 | public function define ( Container $ di ) { foreach ( $ this -> params as $ key => $ value ) { if ( ! isset ( $ di -> values [ $ key ] ) ) { $ di -> values [ $ key ] = $ value ; } } $ this -> defineView ( $ di ) ; $ this -> defineHelpers ( $ di ) ; } | Define Aura \ View and Aura \ Html factories and services |
19,882 | protected function defineHelpers ( Container $ di ) { $ di -> set ( self :: HELPER_FACTORY , $ di -> lazyNew ( Html \ HelperLocatorFactory :: class ) ) ; $ di -> set ( self :: HELPER_LOCATOR , $ di -> lazyGetCall ( self :: HELPER_FACTORY , 'newInstance' ) ) ; $ di -> set ( self :: ESCAPER_FACTORY , $ di -> lazyNew ( Html \ EscaperFactory :: class ) ) ; $ di -> set ( self :: ESCAPER , $ di -> lazyGetCall ( self :: ESCAPER_FACTORY , 'newInstance' ) ) ; $ di -> params [ Html \ Helper \ AbstractHelper :: class ] = [ 'escaper' => $ di -> lazyGet ( self :: ESCAPER ) ] ; } | Define Aura \ Html factories and services |
19,883 | protected function defineView ( Container $ di ) { $ di -> set ( self :: VIEW_FACTORY , $ di -> lazyNew ( View \ ViewFactory :: class ) ) ; $ di -> set ( self :: VIEW , $ di -> lazyGetCall ( View \ ViewFactory :: class , 'newInstance' , $ di -> lazyGet ( self :: HELPER_LOCATOR ) , $ di -> lazyValue ( self :: VIEW_MAP ) , $ di -> lazyValue ( self :: VIEW_PATHS ) , $ di -> lazyValue ( self :: LAYOUT_MAP ) , $ di -> lazyValue ( self :: LAYOUT_PATHS ) ) ) ; } | Define Aura \ View factories and services |
19,884 | public function modify ( Container $ di ) { $ specs = $ di -> lazyValue ( self :: HELPER_SPECS ) ; $ specs = $ specs ( ) ; if ( ! $ specs ) { return ; } $ helpers = $ di -> get ( self :: HELPER_LOCATOR ) ; $ resolve = $ di -> newResolutionHelper ( ) ; foreach ( $ specs as $ key => $ spec ) { $ factory = function ( ) use ( $ resolve , $ spec ) { return $ resolve ( $ spec ) ; } ; $ helpers -> set ( $ key , $ factory ) ; } } | Define Add helpers |
19,885 | public function setMin ( float $ min ) : Number { $ this -> attributes [ 'min' ] = $ min ; return $ this -> addTest ( 'min' , function ( $ value ) use ( $ min ) { return $ value >= $ min ; } ) ; } | Set the minimum value . |
19,886 | public function setMax ( float $ max ) : Number { $ this -> attributes [ 'max' ] = $ max ; return $ this -> addTest ( 'max' , function ( $ value ) use ( $ max ) { return $ value <= $ max ; } ) ; } | Set the maximum value . |
19,887 | public function setStep ( float $ step ) : Number { $ this -> attributes [ 'step' ] = $ step ; $ offset = isset ( $ this -> attributes [ 'min' ] ) ? $ this -> attributes [ 'min' ] : 0 ; return $ this -> addTest ( 'step' , function ( $ value ) use ( $ step , $ offset ) { if ( ! is_numeric ( $ value ) ) { return false ; } return ! fmod ( $ value - $ offset , $ step ) ; } ) ; } | Set the allowed step interval . |
19,888 | public function icon ( $ name , $ options = [ ] ) { $ options = $ this -> parseOptions ( $ options ) ; $ options [ 'class' ] = $ this -> getClasses ( $ name , Arr :: pull ( $ options , 'class' ) ) ; return new HtmlString ( $ this -> openTag ( $ this -> attributes ( $ options ) ) . $ this -> closeTag ( ) ) ; } | Builds a FontAwesome icon HTML . |
19,889 | public function ini ( $ related , $ model , $ local = null , $ remote = null ) { $ this -> checkModels ( $ related , $ model ) ; $ relationVal = $ this -> relationValue ( $ related , $ model , $ local ) ; $ relationColumn = $ this -> relationColumn ( $ related , $ model , $ remote ) ; $ mod = $ this -> first ( $ related , $ relationColumn , $ relationVal ) ; return $ this -> prepare ( $ mod , $ related ) ; } | The one to one relation . |
19,890 | protected function relationColumn ( $ related , $ model , $ column = null ) { $ table = $ related :: $ table ; return ! is_null ( $ column ) ? $ column : $ this -> idKey ( $ table ) ; } | get the name of the column of the relation . |
19,891 | protected function first ( $ model , $ column , $ value ) { $ data = $ model :: where ( $ column , '=' , $ value ) ; if ( ! is_null ( $ data ) ) { if ( count ( $ data ) > 0 ) { return $ data [ 0 ] ; } } } | Get the object for the relation one to one . |
19,892 | public function compile ( ) { if ( $ this -> isCompiled ( ) ) { return $ this -> _compiled ; } $ g11n = G11n :: registry ( ) ; if ( $ g11n -> isEnabled ( ) ) { if ( mb_substr ( $ this -> getPath ( ) , 0 , 9 ) !== '/<locale>' ) { $ this -> prepend ( '/<locale>' ) ; } $ this -> setConfig ( 'patterns.locale' , self :: LOCALE ) ; $ this -> setConfig ( 'locale' , G11n :: canonicalize ( $ g11n -> getFallback ( ) -> getCode ( ) ) ) ; } return parent :: compile ( ) ; } | Prepend the locale to the front of the route before compilation . |
19,893 | public function add_rule ( $ name , $ value , $ rules ) { $ this -> fieldsState [ $ name ] = array ( 'name' => $ name , 'value' => $ value , 'rules' => explode ( '|' , $ rules ) , 'valid' => TRUE , 'message' => NULL ) ; } | Agregar una regla de validacion que luego sera validada |
19,894 | public function validate ( ) { if ( count ( $ this -> fieldsState ) == 0 ) { return TRUE ; } else { $ form_valid = TRUE ; foreach ( $ this -> fieldsState as $ fieldState ) { $ valid = TRUE ; foreach ( $ fieldState [ 'rules' ] as $ rule ) { if ( count ( explode ( '[' , $ rule ) ) > 1 ) { $ vars = explode ( '[' , $ rule ) ; $ rule = $ vars [ 0 ] ; $ var = explode ( ']' , $ vars [ 1 ] ) ; $ var = $ var [ 0 ] ; $ valid = call_user_func_array ( array ( $ this , $ rule ) , array ( $ fieldState [ 'name' ] , $ fieldState [ 'value' ] , $ var ) ) ; } else { $ valid = call_user_func_array ( array ( $ this , $ rule ) , array ( $ fieldState [ 'name' ] , $ fieldState [ 'value' ] ) ) ; } if ( ! $ valid ) { $ name = $ fieldState [ 'name' ] ; $ this -> fieldsState [ "$name" ] [ 'valid' ] = FALSE ; break ; } } $ form_valid = $ form_valid && $ valid ; } return $ form_valid ; } } | Ejecuta todas las reglas de validacion que se hayan cargado . Devuelve TRUE si todas las reglas pasan y FALSE en caso contrario |
19,895 | public function error_messages ( ) { $ messages = array ( ) ; foreach ( $ this -> fieldsState as $ fieldState ) { if ( ! $ fieldState [ 'valid' ] ) { $ name = $ fieldState [ 'name' ] ; $ messages [ "$name" ] = $ fieldState [ 'message' ] ; } } return $ messages ; } | Devuelve los mensajes de error para cada campo que no haya pasado la validacion . Es un array asociativo con el nombre del campo pasado |
19,896 | protected function add_message ( $ name , $ message , $ parametros = array ( ) ) { $ this -> load_messages ( ) ; $ message = $ this -> messages [ $ message ] ; foreach ( $ parametros as $ key => $ valor ) { $ message = str_replace ( ":$key" , $ valor , $ message ) ; } $ this -> fieldsState [ "$name" ] [ 'message' ] = $ message ; } | Funcion utilizada internamente para agregar mensajes de error a los campos |
19,897 | protected function load_messages ( ) { if ( $ this -> messages == NULL || $ this -> locale != $ this -> messagesLocale ) { if ( $ this -> locale != NULL ) { if ( file_exists ( $ this -> dir_content . "_$this->locale" . '.txt' ) ) { $ this -> messages = file ( $ this -> dir_content . "_$this->locale" . '.txt' ) ; $ this -> messages = $ this -> parse_properties ( $ this -> messages ) ; $ this -> messagesLocale = $ this -> locale ; } } if ( $ this -> messages == NULL ) { $ this -> messages = file ( $ this -> dir_content . '.txt' ) ; $ this -> messages = $ this -> parse_properties ( $ this -> messages ) ; $ this -> messagesLocale = NULL ; } } } | Carga el archivo de mensajes en la primer llamada |
19,898 | protected function parse_properties ( $ lines ) { $ result = NULL ; foreach ( $ lines as $ i => $ line ) { if ( empty ( $ line ) || ! isset ( $ line ) || strpos ( $ line , "#" ) === 0 ) { continue ; } $ key = substr ( $ line , 0 , strpos ( $ line , '=' ) ) ; $ value = substr ( $ line , strpos ( $ line , '=' ) + 1 , strlen ( $ line ) ) ; $ result [ $ key ] = $ value ; } return $ result ; } | Este proceso analiza de a una las lineas del archivo de mensajes usado . En este caso txt y me arma lo que seria un array asociativo clave valor en base a la linea . |
19,899 | protected function encapsulate ( ) { $ this -> encapsulated = true ; $ args = func_get_args ( ) ; $ function = array_shift ( $ args ) ; $ content = '' ; ob_start ( function ( $ buffer ) use ( & $ content ) { $ content .= $ buffer ; return '' ; } ) ; $ level = ob_get_level ( ) ; $ applicationClosed = null ; $ statusCodeBefore = http_response_code ( ) ; $ this -> encapsulatedException = null ; try { call_user_func_array ( $ function , $ args ) ; } catch ( ApplicationClosedException $ e ) { } catch ( \ Exception $ e ) { $ this -> encapsulatedException = $ e ; } $ this -> restoreBufferLevel ( $ level ) ; ob_end_clean ( ) ; $ newStatusCode = http_response_code ( ) ; $ this -> response -> setStatusCode ( $ newStatusCode ) ; if ( $ statusCodeBefore != $ newStatusCode ) { http_response_code ( $ statusCodeBefore ) ; } $ headers = $ this -> cleanHeaders ( ) ; foreach ( $ headers as $ name => $ value ) { $ this -> response -> headers -> set ( $ name , $ value ) ; } $ this -> encapsulated = false ; if ( $ this -> encapsulatedException != null ) { throw new JoomlaRequestException ( "Encapsulated request to joomla failed" , 0 , $ this -> encapsulatedException ) ; } return $ content ; } | This method executes code related to the Joomla code and builds a correct response if required |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.