idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
15,100 | public function getParameterTypes ( \ ReflectionParameter $ parameter ) : array { $ name = $ parameter -> getName ( ) ; $ function = $ parameter -> getDeclaringFunction ( ) ; $ types = $ this -> getFunctionParameterTypes ( $ function ) ; return isset ( $ types [ $ name ] ) ? $ types [ $ name ] : [ ] ; } | Returns the types documented on a parameter . |
15,101 | public function getPropertyTypes ( \ ReflectionProperty $ property ) : array { $ docComment = $ property -> getDocComment ( ) ; if ( $ docComment === false ) { return [ ] ; } if ( preg_match ( '/@var\s+(\S+)/' , $ docComment , $ matches ) !== 1 ) { return [ ] ; } return explode ( '|' , $ matches [ 1 ] ) ; } | Returns the types documented on a property . |
15,102 | public function getPropertyClass ( \ ReflectionProperty $ property ) : ? string { $ types = $ this -> getPropertyTypes ( $ property ) ; if ( count ( $ types ) === 1 ) { $ type = $ types [ 0 ] ; if ( $ type [ 0 ] === '\\' ) { return substr ( $ type , 1 ) ; } } return null ; } | Returns the fully qualified class name documented for the given property . |
15,103 | public function exportFunction ( \ ReflectionFunctionAbstract $ function , int $ excludeModifiers = 0 ) : string { $ result = '' ; if ( $ function instanceof \ ReflectionMethod ) { $ modifiers = $ function -> getModifiers ( ) ; $ modifiers &= ~ $ excludeModifiers ; foreach ( \ Reflection :: getModifierNames ( $ modifiers ) as $ modifier ) { $ result .= $ modifier . ' ' ; } } $ result .= 'function ' . $ function -> getShortName ( ) ; $ result .= '(' . $ this -> exportFunctionParameters ( $ function ) . ')' ; if ( null !== $ returnType = $ function -> getReturnType ( ) ) { $ result .= ' : ' ; if ( $ returnType -> allowsNull ( ) ) { $ result .= '?' ; } if ( ! $ returnType -> isBuiltin ( ) ) { $ result .= '\\' ; } $ result .= $ returnType -> getName ( ) ; } return $ result ; } | Exports the function signature . |
15,104 | private function cache ( string $ method , $ object , callable $ callback ) { $ hash = spl_object_hash ( $ object ) ; if ( ! isset ( $ this -> cache [ $ method ] [ $ hash ] ) ) { $ this -> cache [ $ method ] [ $ hash ] = $ callback ( ) ; } return $ this -> cache [ $ method ] [ $ hash ] ; } | Caches the output of a worker function . |
15,105 | public function getAssignmentAttribute ( ) { if ( ! $ this -> exists ) { return static :: ALL_PAGES ; } $ count = $ this -> menuPivot ( ) -> count ( ) ; if ( $ count === 0 ) { return static :: NO_PAGES ; } elseif ( $ count > 1 ) { return static :: SELECTED_PAGES ; } elseif ( $ count === 1 ) { $ pivot = $ this -> menuPivot ( ) -> first ( ) ; if ( $ pivot -> menu_id > 0 ) { return static :: SELECTED_PAGES ; } } return static :: ALL_PAGES ; } | Get menu assignment attribute . |
15,106 | public function menuPivot ( ) { return $ this -> getConnection ( ) -> table ( 'widget_menu' ) -> where ( 'widget_id' , $ this -> id ) -> orWhere ( function ( $ query ) { $ query -> where ( 'menu_id' , 0 ) -> where ( 'widget_id' , $ this -> id ) ; } ) ; } | Get related menus . |
15,107 | public function syncMenuAssignment ( $ menu , $ assignment ) { switch ( $ assignment ) { case static :: ALL_PAGES : $ this -> menus ( ) -> sync ( [ static :: ALL_PAGES ] ) ; break ; case static :: NO_PAGES : $ this -> menus ( ) -> detach ( ) ; break ; case static :: SELECTED_PAGES : $ this -> menus ( ) -> sync ( $ menu ) ; break ; } return $ this ; } | Sync widget menu assignment . |
15,108 | public function install ( $ type , array $ attributes ) { $ extension = new Extension ; $ extension -> type = $ type ; $ extension -> name = $ attributes [ 'name' ] ; if ( isset ( $ attributes [ 'parameters' ] ) ) { $ extension -> parameters = $ attributes [ 'parameters' ] ; } $ extension -> manifest = json_encode ( $ attributes ) ; $ extension -> save ( ) ; return $ extension ; } | Install an extension . |
15,109 | public function uninstall ( $ id ) { $ extension = $ this -> getModel ( ) -> query ( ) -> findOrFail ( $ id ) ; $ extension -> delete ( ) ; } | Uninstall extension . |
15,110 | public function registerManifest ( $ path ) { if ( ! File :: exists ( $ path ) ) { throw new \ Exception ( 'Extension manifest file does not exist! Path: ' . $ path ) ; } $ manifest = File :: get ( $ path ) ; $ manifest = json_decode ( $ manifest , true ) ; $ this -> register ( $ manifest ) ; } | Register an extension using manifest config file . |
15,111 | protected function isNextTokenAnException ( $ tokens , $ ptr ) { return in_array ( $ tokens [ ( $ ptr + 1 ) ] [ 'code' ] , $ this -> exceptions ) && $ tokens [ ( $ ptr + 1 ) ] [ 'column' ] - $ tokens [ ( $ ptr ) ] [ 'column' ] == 1 ; } | check whether the next token of the current one is an exception |
15,112 | public function ajustarNossoNumero ( ArrayObject $ data ) { $ carteira = $ this -> carteira ; switch ( strlen ( $ this -> convenio ) ) { case 6 : if ( ! $ carteira instanceof Carteira21 ) { $ data [ 'NossoNumero' ] = $ this -> convenio . $ data [ 'NossoNumero' ] ; } break ; case 4 : case 7 : $ data [ 'NossoNumero' ] = $ this -> convenio . $ data [ 'NossoNumero' ] ; break ; default : throw new \ LogicException ( 'O codigo do convenio precisa ter 4, 6 ou 7 digitos!' ) ; } return $ data ; } | Ajusta o Nosso Numero antes de seta - lo no objeto Convenio . |
15,113 | public function buildResponseIfApplicable ( Request $ httpRequest ) { try { $ redirect = $ this -> redirectStorage -> getOneBySourceUriPathAndHost ( $ httpRequest -> getRelativePath ( ) , $ httpRequest -> getBaseUri ( ) -> getHost ( ) ) ; if ( $ redirect === null ) { return null ; } if ( isset ( $ this -> featureSwitch [ 'hitCounter' ] ) && $ this -> featureSwitch [ 'hitCounter' ] === true ) { $ this -> redirectStorage -> incrementHitCount ( $ redirect ) ; } return $ this -> buildResponse ( $ httpRequest , $ redirect ) ; } catch ( \ Exception $ exception ) { if ( $ exception instanceof Exception ) { throw $ exception ; } return null ; } } | Searches for a matching redirect for the given HTTP response |
15,114 | public function setServer ( $ host , $ port = 0 ) { assert ( is_string ( $ host ) ) ; if ( $ host [ 0 ] == '/' ) { $ this -> _path = 'unix://' . $ host ; return ; } if ( substr ( $ host , 0 , 7 ) == 'unix://' ) { $ this -> _path = $ host ; return ; } $ this -> _host = $ host ; if ( is_int ( $ port ) ) { if ( $ port ) { $ this -> _port = $ port ; } } $ this -> _path = '' ; return $ this ; } | Sets the searchd host name and port . |
15,115 | public function setLimits ( $ offset , $ limit , $ max = 0 , $ cutoff = 0 ) { assert ( is_int ( $ offset ) ) ; assert ( is_int ( $ limit ) ) ; assert ( is_int ( $ max ) ) ; assert ( is_int ( $ cutoff ) ) ; assert ( $ offset >= 0 ) ; assert ( $ limit > 0 ) ; assert ( $ max >= 0 ) ; assert ( $ cutoff >= 0 ) ; $ this -> _offset = $ offset ; $ this -> _limit = $ limit ; if ( $ max > 0 ) { $ this -> _maxmatches = $ max ; } if ( $ cutoff > 0 ) { $ this -> _cutoff = $ cutoff ; } return $ this ; } | Sets an offset and count into result set and optionally set max - matches and cutoff limits . |
15,116 | public function setMaxQueryTime ( $ max ) { assert ( is_int ( $ max ) ) ; assert ( $ max >= 0 ) ; $ this -> _maxquerytime = $ max ; return $ this ; } | Set maximum query time in milliseconds per - index . Integer 0 means do not limit . |
15,117 | public function setMatchMode ( $ mode ) { assert ( $ mode == SPH_MATCH_ALL || $ mode == SPH_MATCH_ANY || $ mode == SPH_MATCH_PHRASE || $ mode == SPH_MATCH_BOOLEAN || $ mode == SPH_MATCH_EXTENDED || $ mode == SPH_MATCH_FULLSCAN || $ mode == SPH_MATCH_EXTENDED2 ) ; $ this -> _mode = $ mode ; return $ this ; } | Sets a matching mode . |
15,118 | public function setRankingMode ( $ ranker , $ rankexpr = '' ) { assert ( $ ranker === 0 || $ ranker >= 1 && $ ranker < SPH_RANK_TOTAL ) ; assert ( is_string ( $ rankexpr ) ) ; $ this -> _ranker = $ ranker ; $ this -> _rankexpr = $ rankexpr ; return $ this ; } | Sets ranking mode . |
15,119 | public function setIndexWeights ( array $ weights ) { assert ( is_array ( $ weights ) ) ; foreach ( $ weights as $ index => $ weight ) { assert ( is_string ( $ index ) ) ; assert ( is_int ( $ weight ) ) ; } $ this -> _indexweights = $ weights ; return $ this ; } | Bind per - index weights by name . |
15,120 | public function setRetries ( $ count , $ delay = 0 ) { assert ( is_int ( $ count ) && $ count >= 0 ) ; assert ( is_int ( $ delay ) && $ delay >= 0 ) ; $ this -> _retrycount = $ count ; $ this -> _retrydelay = $ delay ; return $ this ; } | Sets distributed retries count and delay values . |
15,121 | public function query ( $ query , $ index = '*' , $ comment = '' ) { assert ( empty ( $ this -> _reqs ) ) ; $ this -> AddQuery ( $ query , $ index , $ comment ) ; $ results = $ this -> RunQueries ( ) ; $ this -> _reqs = array ( ) ; if ( ! is_array ( $ results ) ) { return false ; } $ this -> _error = $ results [ 0 ] [ 'error' ] ; $ this -> _warning = $ results [ 0 ] [ 'warning' ] ; if ( $ results [ 0 ] [ 'status' ] == SEARCHD_ERROR ) { return false ; } else { return $ results [ 0 ] ; } } | Connects to searchd server run given search query through given indexes and returns the search results . |
15,122 | public function runQueries ( ) { if ( empty ( $ this -> _reqs ) ) { $ this -> _error = 'no queries defined, issue AddQuery() first' ; return false ; } $ this -> _MBPush ( ) ; if ( ! ( $ fp = $ this -> _Connect ( ) ) ) { $ this -> _MBPop ( ) ; return false ; } $ nreqs = count ( $ this -> _reqs ) ; $ req = implode ( '' , $ this -> _reqs ) ; $ len = 8 + strlen ( $ req ) ; $ req = pack ( 'nnNNN' , SEARCHD_COMMAND_SEARCH , VER_COMMAND_SEARCH , $ len , 0 , $ nreqs ) . $ req ; if ( ! ( $ this -> _Send ( $ fp , $ req , $ len + 8 ) ) || ! ( $ response = $ this -> _GetResponse ( $ fp , VER_COMMAND_SEARCH ) ) ) { $ this -> _MBPop ( ) ; return false ; } $ this -> _reqs = array ( ) ; return $ this -> _ParseSearchResponse ( $ response , $ nreqs ) ; } | Connects to searchd runs queries in batch and returns an array of result sets . |
15,123 | public function open ( ) { if ( $ this -> _socket !== false ) { $ this -> _error = 'already connected' ; return false ; } if ( ! $ fp = $ this -> _Connect ( ) ) { return false ; } $ req = pack ( 'nnNN' , SEARCHD_COMMAND_PERSIST , 0 , 4 , 1 ) ; if ( ! $ this -> _Send ( $ fp , $ req , 12 ) ) { return false ; } $ this -> _socket = $ fp ; return true ; } | Opens the connection to searchd . |
15,124 | public function close ( ) { if ( $ this -> _socket === false ) { $ this -> _error = 'not connected' ; return false ; } fclose ( $ this -> _socket ) ; $ this -> _socket = false ; return true ; } | Closes the connection to searchd . |
15,125 | public function status ( ) { $ this -> _MBPush ( ) ; if ( ! ( $ fp = $ this -> _Connect ( ) ) ) { $ this -> _MBPop ( ) ; return false ; } $ req = pack ( 'nnNN' , SEARCHD_COMMAND_STATUS , VER_COMMAND_STATUS , 4 , 1 ) ; if ( ! ( $ this -> _Send ( $ fp , $ req , 12 ) ) || ! ( $ response = $ this -> _GetResponse ( $ fp , VER_COMMAND_STATUS ) ) ) { $ this -> _MBPop ( ) ; return false ; } substr ( $ response , 4 ) ; $ p = 0 ; list ( $ rows , $ cols ) = array_values ( unpack ( 'N*N*' , substr ( $ response , $ p , 8 ) ) ) ; $ p += 8 ; $ res = array ( ) ; for ( $ i = 0 ; $ i < $ rows ; ++ $ i ) { for ( $ j = 0 ; $ j < $ cols ; ++ $ j ) { list ( , $ len ) = unpack ( 'N*' , substr ( $ response , $ p , 4 ) ) ; $ p += 4 ; $ res [ $ i ] [ ] = substr ( $ response , $ p , $ len ) ; $ p += $ len ; } } $ this -> _MBPop ( ) ; return $ res ; } | Checks the searchd status . |
15,126 | public function removeFilter ( $ attribute ) { assert ( is_string ( $ attribute ) ) ; foreach ( $ this -> _filters as $ key => $ filter ) { if ( $ filter [ 'attr' ] == $ attribute ) { unset ( $ this -> _filters [ $ key ] ) ; return $ this ; } } return $ this ; } | Removes a previously set filter . |
15,127 | protected function _Connect ( ) { if ( $ this -> _socket !== false ) { if ( ! @ feof ( $ this -> _socket ) ) { return $ this -> _socket ; } $ this -> _socket = false ; } $ errno = 0 ; $ errstr = '' ; $ this -> _connerror = false ; if ( $ this -> _path ) { $ host = $ this -> _path ; $ port = 0 ; } else { $ host = $ this -> _host ; $ port = $ this -> _port ; } if ( $ this -> _timeout <= 0 ) { $ fp = @ fsockopen ( $ host , $ port , $ errno , $ errstr ) ; } else { $ fp = @ fsockopen ( $ host , $ port , $ errno , $ errstr , $ this -> _timeout ) ; } if ( ! $ fp ) { if ( $ this -> _path ) { $ location = $ this -> _path ; } else { $ location = "{$this->_host}:{$this->_port}" ; } $ errstr = trim ( $ errstr ) ; $ this -> _error = "connection to $location failed (errno=$errno, msg=$errstr)" ; $ this -> _connerror = true ; return false ; } if ( ! $ this -> _Send ( $ fp , pack ( 'N' , 1 ) , 4 ) ) { fclose ( $ fp ) ; $ this -> _error = 'failed to send client protocol version' ; return false ; } list ( , $ v ) = unpack ( 'N*' , fread ( $ fp , 4 ) ) ; $ v = ( int ) $ v ; if ( $ v < 1 ) { fclose ( $ fp ) ; $ this -> _error = "expected searchd protocol version 1+, got version '$v'" ; return false ; } return $ fp ; } | Connect to searchd server . |
15,128 | protected function _GetResponse ( $ fp , $ client_ver ) { $ status = '' ; $ response = '' ; $ len = 0 ; $ ver = '' ; $ header = fread ( $ fp , 8 ) ; if ( strlen ( $ header ) == 8 ) { list ( $ status , $ ver , $ len ) = array_values ( unpack ( 'n2a/Nb' , $ header ) ) ; $ left = $ len ; while ( $ left > 0 && ! feof ( $ fp ) ) { $ chunk = fread ( $ fp , min ( 8192 , $ left ) ) ; if ( $ chunk ) { $ response .= $ chunk ; $ left -= strlen ( $ chunk ) ; } } } if ( $ this -> _socket === false ) { fclose ( $ fp ) ; } $ read = strlen ( $ response ) ; if ( ! $ response || $ read != $ len ) { $ this -> _error = $ len ? "failed to read searchd response (status=$status, ver=$ver, len=$len, read=$read)" : 'received zero-sized searchd response' ; return false ; } if ( $ status == SEARCHD_WARNING ) { list ( $ temp , $ wlen ) = unpack ( 'N*' , substr ( $ response , 0 , 4 ) ) ; unset ( $ temp ) ; $ this -> _warning = substr ( $ response , 4 , $ wlen ) ; return substr ( $ response , 4 + $ wlen ) ; } if ( $ status == SEARCHD_ERROR ) { $ this -> _error = 'searchd error: ' . substr ( $ response , 4 ) ; return false ; } if ( $ status == SEARCHD_RETRY ) { $ this -> _error = 'temporary searchd error: ' . substr ( $ response , 4 ) ; return false ; } if ( $ status != SEARCHD_OK ) { $ this -> _error = "unknown status code '$status'" ; return false ; } if ( $ ver < $ client_ver ) { $ this -> _warning = sprintf ( "searchd command v.%d.%d older than client's v.%d.%d, some options might not work" , $ ver >> 8 , $ ver & 0xff , $ client_ver >> 8 , $ client_ver & 0xff ) ; } return $ response ; } | Get and check response packet from searchd server . |
15,129 | protected function sphPackI64 ( $ v ) { assert ( is_numeric ( $ v ) ) ; if ( PHP_INT_SIZE >= 8 ) { $ v = ( int ) $ v ; return pack ( 'NN' , $ v >> 32 , $ v & 0xFFFFFFFF ) ; } if ( is_int ( $ v ) ) { return pack ( 'NN' , $ v < 0 ? - 1 : 0 , $ v ) ; } if ( function_exists ( 'bcmul' ) ) { if ( bccomp ( $ v , 0 ) == - 1 ) { $ v = bcadd ( '18446744073709551616' , $ v ) ; } $ h = bcdiv ( $ v , '4294967296' , 0 ) ; $ l = bcmod ( $ v , '4294967296' ) ; return pack ( 'NN' , ( float ) $ h , ( float ) $ l ) ; } $ p = max ( 0 , strlen ( $ v ) - 13 ) ; $ lo = abs ( ( float ) substr ( $ v , $ p ) ) ; $ hi = abs ( ( float ) substr ( $ v , 0 , $ p ) ) ; $ m = $ lo + $ hi * 1316134912.0 ; $ q = floor ( $ m / 4294967296.0 ) ; $ l = $ m - ( $ q * 4294967296.0 ) ; $ h = $ hi * 2328.0 + $ q ; if ( $ v < 0 ) { if ( $ l == 0 ) { $ h = 4294967296.0 - $ h ; } else { $ h = 4294967295.0 - $ h ; $ l = 4294967296.0 - $ l ; } } return pack ( 'NN' , $ h , $ l ) ; } | Pack 64 - bit signed . |
15,130 | protected function sphPackU64 ( $ v ) { assert ( is_numeric ( $ v ) ) ; if ( PHP_INT_SIZE >= 8 ) { assert ( $ v >= 0 ) ; if ( is_int ( $ v ) ) { return pack ( 'NN' , $ v >> 32 , $ v & 0xFFFFFFFF ) ; } if ( function_exists ( 'bcmul' ) ) { $ h = bcdiv ( $ v , 4294967296 , 0 ) ; $ l = bcmod ( $ v , 4294967296 ) ; return pack ( 'NN' , $ h , $ l ) ; } $ p = max ( 0 , strlen ( $ v ) - 13 ) ; $ lo = ( int ) substr ( $ v , $ p ) ; $ hi = ( int ) substr ( $ v , 0 , $ p ) ; $ m = $ lo + $ hi * 1316134912 ; $ l = $ m % 4294967296 ; $ h = $ hi * 2328 + ( int ) ( $ m / 4294967296 ) ; return pack ( 'NN' , $ h , $ l ) ; } if ( is_int ( $ v ) ) { return pack ( 'NN' , 0 , $ v ) ; } if ( function_exists ( 'bcmul' ) ) { $ h = bcdiv ( $ v , '4294967296' , 0 ) ; $ l = bcmod ( $ v , '4294967296' ) ; return pack ( 'NN' , ( float ) $ h , ( float ) $ l ) ; } $ p = max ( 0 , strlen ( $ v ) - 13 ) ; $ lo = ( float ) substr ( $ v , $ p ) ; $ hi = ( float ) substr ( $ v , 0 , $ p ) ; $ m = $ lo + $ hi * 1316134912.0 ; $ q = floor ( $ m / 4294967296.0 ) ; $ l = $ m - ( $ q * 4294967296.0 ) ; $ h = $ hi * 2328.0 + $ q ; return pack ( 'NN' , $ h , $ l ) ; } | Packs 64 - bit unsigned . |
15,131 | protected function sphUnpackU64 ( $ v ) { list ( $ hi , $ lo ) = array_values ( unpack ( 'N*N*' , $ v ) ) ; if ( PHP_INT_SIZE >= 8 ) { if ( $ hi < 0 ) { $ hi += ( 1 << 32 ) ; } if ( $ lo < 0 ) { $ lo += ( 1 << 32 ) ; } if ( $ hi <= 2147483647 ) { return ( $ hi << 32 ) + $ lo ; } if ( function_exists ( 'bcmul' ) ) { return bcadd ( $ lo , bcmul ( $ hi , '4294967296' ) ) ; } $ C = 100000 ; $ h = ( ( int ) ( $ hi / $ C ) << 32 ) + ( int ) ( $ lo / $ C ) ; $ l = ( ( $ hi % $ C ) << 32 ) + ( $ lo % $ C ) ; if ( $ l > $ C ) { $ h += ( int ) ( $ l / $ C ) ; $ l = $ l % $ C ; } if ( $ h == 0 ) { return $ l ; } return sprintf ( '%d%05d' , $ h , $ l ) ; } if ( $ hi == 0 ) { if ( $ lo > 0 ) { return $ lo ; } return sprintf ( '%u' , $ lo ) ; } $ hi = sprintf ( '%u' , $ hi ) ; $ lo = sprintf ( '%u' , $ lo ) ; if ( function_exists ( 'bcmul' ) ) { return bcadd ( $ lo , bcmul ( $ hi , '4294967296' ) ) ; } $ hi = ( float ) $ hi ; $ lo = ( float ) $ lo ; $ q = floor ( $ hi / 10000000.0 ) ; $ r = $ hi - $ q * 10000000.0 ; $ m = $ lo + $ r * 4967296.0 ; $ mq = floor ( $ m / 10000000.0 ) ; $ l = $ m - $ mq * 10000000.0 ; $ h = $ q * 4294967296.0 + $ r * 429.0 + $ mq ; $ h = sprintf ( '%.0f' , $ h ) ; $ l = sprintf ( '%07.0f' , $ l ) ; if ( $ h == '0' ) { return sprintf ( '%.0f' , ( float ) $ l ) ; } return $ h . $ l ; } | Unpacks 64 - bit unsigned . |
15,132 | protected function sphUnpackI64 ( $ v ) { list ( $ hi , $ lo ) = array_values ( unpack ( 'N*N*' , $ v ) ) ; if ( PHP_INT_SIZE >= 8 ) { if ( $ hi < 0 ) { $ hi += ( 1 << 32 ) ; } if ( $ lo < 0 ) { $ lo += ( 1 << 32 ) ; } return ( $ hi << 32 ) + $ lo ; } if ( $ hi == 0 ) { if ( $ lo > 0 ) { return $ lo ; } return sprintf ( '%u' , $ lo ) ; } elseif ( $ hi == - 1 ) { if ( $ lo < 0 ) { return $ lo ; } return sprintf ( '%.0f' , $ lo - 4294967296.0 ) ; } $ neg = '' ; $ c = 0 ; if ( $ hi < 0 ) { $ hi = ~ $ hi ; $ lo = ~ $ lo ; $ c = 1 ; $ neg = '-' ; } $ hi = sprintf ( '%u' , $ hi ) ; $ lo = sprintf ( '%u' , $ lo ) ; if ( function_exists ( 'bcmul' ) ) { return $ neg . bcadd ( bcadd ( $ lo , bcmul ( $ hi , '4294967296' ) ) , $ c ) ; } $ hi = ( float ) $ hi ; $ lo = ( float ) $ lo ; $ q = floor ( $ hi / 10000000.0 ) ; $ r = $ hi - $ q * 10000000.0 ; $ m = $ lo + $ r * 4967296.0 ; $ mq = floor ( $ m / 10000000.0 ) ; $ l = $ m - $ mq * 10000000.0 + $ c ; $ h = $ q * 4294967296.0 + $ r * 429.0 + $ mq ; if ( $ l == 10000000 ) { $ l = 0 ; $ h += 1 ; } $ h = sprintf ( '%.0f' , $ h ) ; $ l = sprintf ( '%07.0f' , $ l ) ; if ( $ h == '0' ) { return $ neg . sprintf ( '%.0f' , ( float ) $ l ) ; } return $ neg . $ h . $ l ; } | Unpacks 64 - bit signed . |
15,133 | public function actionTree ( ) { $ models = Category :: find ( ) -> orderBy ( 'position DESC, title' ) -> all ( ) ; $ model = new Category ( ) ; return $ this -> render ( 'tree' , [ 'model' => $ model , 'models' => $ models , ] ) ; } | Displays categories as tree . |
15,134 | public function store ( Request $ request ) { $ this -> validate ( $ request , [ 'theme' => 'required' , ] ) ; $ config = Configuration :: query ( ) -> firstOrCreate ( [ 'key' => 'theme.frontend' ] ) ; $ config -> value = $ request -> get ( 'theme' ) ; $ config -> save ( ) ; flash ( ) -> success ( trans ( 'cms::theme.success' , [ 'theme' => $ request -> get ( 'theme' ) ] ) ) ; return back ( ) ; } | Store new default theme . |
15,135 | public function dataTable ( ) { return ( new EloquentDataTable ( $ this -> query ( ) ) ) -> editColumn ( 'lft' , '<i class="fa fa-dot-circle-o"></i>' ) -> addColumn ( 'action' , function ( Category $ category ) { return view ( 'administrator.categories.datatables.action' , $ category -> toArray ( ) ) ; } ) -> editColumn ( 'authenticated' , function ( Category $ category ) { return view ( 'administrator.categories.datatables.authenticated' , $ category -> toArray ( ) ) ; } ) -> addColumn ( 'pub' , function ( Category $ category ) { return '<span class="badge bg-green">' . $ category -> countPublished ( ) . '</span>' ; } ) -> addColumn ( 'unpub' , function ( Category $ category ) { return '<span class="badge bg-yellow">' . $ category -> countUnpublished ( ) . '</span>' ; } ) -> editColumn ( 'hits' , function ( Category $ category ) { return '<span class="badge bg-blue">' . $ category -> hits . '</span>' ; } ) -> editColumn ( 'title' , function ( Category $ category ) { return view ( 'administrator.categories.datatables.title' , compact ( 'category' ) ) ; } ) -> editColumn ( 'created_at' , function ( Category $ category ) { return $ category -> created_at -> format ( 'Y-m-d' ) ; } ) -> rawColumns ( [ 'lft' , 'published' , 'authenticated' , 'hits' , 'title' , 'action' , 'pub' , 'unpub' ] ) ; } | Build DataTable class . |
15,136 | public function getPublishedPosts ( ) { return PostSearch :: find ( ) -> joinWith ( 'category' ) -> where ( [ 'publish_status' => Post :: STATUS_PUBLISHED , 'blog_category.id' => $ this -> id ] ) -> all ( ) ; } | Get published posts |
15,137 | protected function assertEqualsSnapshot ( $ expected , $ identifier = null , $ message = null ) { SnapshotsManager :: setSuite ( $ this ) ; $ snapshot = SnapshotsManager :: upsertSnapshotContents ( $ identifier , $ expected ) ; $ this -> assertEquals ( $ snapshot , $ expected , $ message ) ; } | Asserts that a given output matches a registered snapshot or update the latter if it doesn t exist yet . |
15,138 | public function generatePush ( Array $ parameters , $ label , $ pushCallback , $ pushClass = "\BIPBOP\Client\Push" ) { $ reflection = new \ ReflectionClass ( $ pushClass ) ; $ query = sprintf ( "SELECT FROM '%s'.'%s'" , $ this -> database -> name ( ) , $ this -> domNode -> getAttribute ( "name" ) ) ; $ instance = $ reflection -> newInstance ( $ this -> ws ) ; $ this -> validateParameters ( $ parameters ) ; return $ instance -> create ( $ label , $ pushCallback , $ query , $ parameters ) ; } | Cria um PUSH |
15,139 | protected function recomputeSlug ( ) { $ slug = $ this -> computeSlug ( ) ; $ this -> getConnection ( ) -> table ( $ this -> getTable ( ) ) -> where ( $ this -> getKeyName ( ) , $ this -> id ) -> update ( [ 'slug' => $ slug ] ) ; $ this -> articles ( ) -> get ( ) -> each -> touch ( ) ; } | Recompute category slug and all articles . |
15,140 | public function getUrl ( $ layout = null ) { $ layout = $ layout ? '?layout=' . $ layout : '' ; return url ( $ this -> slug ) . $ layout ; } | Get url from implementing class . |
15,141 | public function addAction ( $ action ) { if ( $ action instanceof AttachmentAction ) { $ this -> actions [ ] = $ action ; return $ this ; } elseif ( is_array ( $ action ) ) { $ this -> actions [ ] = new AttachmentAction ( $ action ) ; return $ this ; } throw new InvalidArgumentException ( 'The attachment action must be an instance of jeremykenedy\Slack\AttachmentAction or a keyed array' ) ; } | Add an action to the attachment . |
15,142 | protected static function boot ( ) { parent :: boot ( ) ; static :: saving ( function ( Article $ article ) { $ article -> slug = $ article -> computeSlug ( ) ; } ) ; } | Boot model . |
15,143 | public function computeSlug ( ) { if ( $ this -> is_page ) { return $ this -> alias ; } if ( ! $ this -> exists ) { $ category = Category :: query ( ) -> findOrFail ( $ this -> category_id ) ; } else { $ category = $ this -> category ; } return $ category -> slug . '/' . $ this -> alias ; } | Compute article slug . |
15,144 | public function getRouteName ( ) { if ( $ this -> is_page ) { return $ this -> alias ; } return str_replace ( 'category-' , '' , $ this -> category -> getRouteName ( ) . '.' . $ this -> alias ) ; } | Get article s route name . |
15,145 | public function visited ( ) { $ this -> hits ++ ; $ this -> newQuery ( ) -> toBase ( ) -> where ( $ this -> getKeyName ( ) , $ this -> getKey ( ) ) -> increment ( 'hits' ) ; return $ this ; } | Update article hits without updating the timestamp . |
15,146 | public function getTemplate ( ) { $ view = 'articles' . str_replace ( '//' , '.' , $ this -> slug ) ; if ( view ( ) -> exists ( $ view ) ) { return $ view ; } return $ this -> hasTemplate ( ) ? $ this -> blade_template : 'article.show' ; } | Get article s template . |
15,147 | protected function createJsonConfig ( $ name ) { if ( $ this -> files -> exists ( $ path = $ this -> getJsonPath ( ) ) ) { $ this -> error ( 'Widget json config already exists!' ) ; return ; } $ stub = $ this -> files -> get ( $ this -> getJsonStubPath ( ) ) ; $ stub = $ this -> replaceNamespace ( $ stub , $ name ) -> replaceClass ( $ stub , $ name ) ; $ stub = $ this -> replaceFQCN ( $ stub , $ name ) ; $ stub = $ this -> replaceView ( $ stub ) ; $ this -> files -> put ( $ path , $ stub ) ; $ this -> info ( 'Json config created successfully.' ) ; } | Create json config file for widget details . |
15,148 | protected function getJsonStubPath ( ) { $ stubPath = $ this -> laravel -> make ( 'config' ) -> get ( 'laravel-widgets.widget_json_stub' ) ; return $ this -> laravel -> basePath ( ) . '/' . $ stubPath ; } | Get json stub path . |
15,149 | protected function createView ( ) { if ( $ this -> files -> exists ( $ path = $ this -> getViewPath ( ) ) ) { $ this -> error ( 'View already exists!' ) ; return ; } $ this -> makeDirectory ( $ path ) ; $ view = $ this -> files -> get ( $ this -> getViewStub ( 'view' ) ) ; $ this -> files -> put ( $ path , $ view ) ; $ form = $ this -> files -> get ( $ this -> getViewStub ( 'form' ) ) ; $ this -> files -> put ( $ this -> getViewPath ( '_form' ) , $ form ) ; $ this -> info ( 'Views successfully created.' ) ; } | Create a new view file for the widget . return void |
15,150 | public function getViewStub ( $ key ) { $ stubPath = $ this -> laravel -> make ( 'config' ) -> get ( 'laravel-widgets.widget_' . $ key . '_stub' ) ; return $ this -> laravel -> basePath ( ) . '/' . $ stubPath ; } | Get widget stub by key . |
15,151 | public function post ( $ query , Array $ parameters = [ ] , $ autoParser = true ) { curl_setopt_array ( $ this -> resource , [ CURLOPT_POSTFIELDS => array_merge ( $ parameters , [ self :: PARAMETER_QUERY => $ query , self :: PARAMETER_APIKEY => $ this -> apiKey ] ) ] ) ; $ dom = new \ DOMDocument ; $ ret = curl_exec ( $ this -> resource ) ; if ( ! $ autoParser ) return $ ret ; $ dom -> loadXML ( $ ret ) ; static :: assert ( $ dom ) ; return $ dom ; } | Realiza a chamada ao WS da BIPBOP |
15,152 | public static function assert ( \ DOMDocument $ dom ) { $ queryNode = ( new \ DOMXPath ( $ dom ) ) -> query ( "/BPQL/header/exception" ) ; if ( $ queryNode -> length ) { $ nodeException = $ queryNode -> item ( 0 ) ; $ source = $ nodeException -> getAttribute ( "source" ) ; $ code = $ nodeException -> getAttribute ( "code" ) ; $ id = $ nodeException -> getAttribute ( "id" ) ; $ pushable = ( $ nodeException -> getAttribute ( "pushable" ) ? : $ nodeException -> getAttribute ( "push" ) ) === "true" ; $ message = $ nodeException -> nodeValue ; $ e = new Exception ( sprintf ( "[%s:%s/%s] %s" , $ code , $ source , $ id , $ message , $ pushable ) , $ code ) ; $ e -> setAttributes ( $ code , $ source , $ id , $ message , $ pushable ) ; throw $ e ; } } | Realiza um assertion do documento |
15,153 | public function browse ( Request $ request , $ filter = null ) { $ this -> template = 'layouts.component' ; $ this -> filter = $ filter ; return $ this -> index ( $ request ) ; } | Display media browser from CKEditor . |
15,154 | protected function folderIsNotAccessible ( Request $ request ) { if ( isset ( $ request [ 'folder' ] ) && empty ( $ request -> get ( 'folder' ) ) ) { return true ; } return ! Storage :: exists ( $ this -> currentDir ) && $ request -> has ( 'folder' ) || $ request -> get ( 'folder' ) === 'public' ; } | Check if current folder and folder being requested is accessible . |
15,155 | protected function scanFiles ( $ current_directory ) { $ files = collect ( Storage :: files ( $ current_directory ) ) ; $ files = $ files -> filter ( function ( $ file ) { $ ext = File :: extension ( $ file ) ; if ( $ this -> filter === 'images' ) { return in_array ( $ ext , $ this -> config -> get ( 'media.images_ext' ) ) ; } elseif ( $ this -> filter === 'files' ) { return in_array ( $ ext , $ this -> config -> get ( 'media.files_ext' ) ) ; } return true ; } ) ; return $ files ; } | Scan files of the given directory . |
15,156 | protected function buildThumbnails ( $ files ) { $ thumbnails = [ ] ; foreach ( $ files as $ file ) { if ( file_can_have_thumbnail ( $ file ) ) { $ thumbnails [ $ file ] = ( string ) $ this -> image -> make ( Storage :: get ( $ file ) ) -> resize ( 20 , 20 ) -> encode ( 'data-url' ) ; } } return $ thumbnails ; } | Build thumbnails for each files that is image type . |
15,157 | protected function buildDirectory ( $ directories , $ parent ) { $ directories = $ directories -> map ( function ( $ dir ) use ( $ parent ) { $ dir = str_replace ( $ parent . '/' , '' , $ dir ) ; return $ dir ; } ) ; $ html = '<ul>' ; $ directories -> each ( function ( $ dir ) use ( & $ html , $ parent ) { $ subParent = $ parent . '/' . $ dir ; $ url = request ( ) -> url ( ) . '?folder=' . $ dir ; $ dir = str_replace ( 'public/' , 'storage/' , $ dir ) ; $ html .= "<li>" ; $ html .= "<a href='{$url}'>{$dir}</a>" ; if ( $ child = $ this -> scanDirectory ( $ subParent ) ) { $ html .= $ this -> buildDirectory ( $ child , $ subParent ) ; } $ html .= "</li>" ; } ) ; $ html .= '</ul>' ; return $ html ; } | Build the directory lists . |
15,158 | protected function deleteDirectory ( Request $ request ) { try { $ dir = $ request -> input ( 's' ) ; Storage :: deleteDirectory ( $ dir ) ; return $ this -> notifySuccess ( $ dir . ' successfully deleted!' ) ; } catch ( \ ErrorException $ e ) { return $ this -> notifyError ( $ e -> getMessage ( ) ) ; } } | Delete a single directory from request . |
15,159 | protected function deleteFile ( Request $ request ) { try { $ file = $ request -> input ( 's' ) ; Storage :: delete ( $ file ) ; return $ this -> notifySuccess ( $ file . ' successfully deleted!' ) ; } catch ( \ ErrorException $ e ) { return $ this -> notifyError ( $ e -> getMessage ( ) ) ; } } | Delete a single file from request . |
15,160 | public function destroy ( $ id ) { $ extension = $ this -> repository -> findOrFail ( $ id ) ; if ( $ extension -> protected ) { return $ this -> notifyError ( trans ( 'cms::extension.protected' ) ) ; } if ( $ this -> repository -> uninstall ( $ id ) ) { flash ( ) -> success ( trans ( 'cms::extension.deleted' , compact ( 'id' ) ) ) ; } else { flash ( ) -> error ( trans ( 'cms::extension.error' , compact ( 'id' ) ) ) ; } return back ( ) ; } | Uninstall an extension . |
15,161 | public function payload ( $ payload , $ format = '' , $ container = 'data' ) { $ class = $ this -> getFormatClass ( $ format ) ; return $ this -> generate ( $ payload , new $ class , $ container ) ; } | Format the payload array autodetect format . Override the format by providing a content type . |
15,162 | public function registerFormat ( $ format , $ class ) { if ( ! class_exists ( $ class ) ) { throw new \ InvalidArgumentException ( "Responder formatter class {$class} not found." ) ; } if ( ! is_a ( $ class , 'Nathanmac\Utilities\Responder\Formats\FormatInterface' , true ) ) { throw new \ InvalidArgumentException ( 'Responder formatters must implement the Nathanmac\Utilities\Responder\Formats\FormatInterface interface.' ) ; } $ this -> supported_formats [ $ format ] = $ class ; return $ this ; } | Register Format Class . |
15,163 | public function handle ( ComponentContext $ componentContext ) { $ routingMatchResults = $ componentContext -> getParameter ( RoutingComponent :: class , 'matchResults' ) ; if ( $ routingMatchResults !== NULL ) { return ; } $ httpRequest = $ componentContext -> getHttpRequest ( ) ; $ response = $ this -> redirectService -> buildResponseIfApplicable ( $ httpRequest ) ; if ( $ response !== null ) { $ componentContext -> replaceHttpResponse ( $ response ) ; $ componentContext -> setParameter ( ComponentChain :: class , 'cancel' , true ) ; } } | Check if the current request match a redirect |
15,164 | public function category ( ) { $ category = $ this -> param ( 'category_id' , 0 ) ; $ categoryId = explode ( ':' , $ category ) [ 0 ] ; return Category :: query ( ) -> findOrNew ( $ categoryId ) ; } | Get related category . |
15,165 | public function hasWidget ( $ widget ) { if ( $ widget instanceof Model ) { $ widget = $ widget -> id ; } return $ this -> widgets ( ) -> where ( 'widget_id' , $ widget ) -> exists ( ) ; } | Check if the menu has the given widget . |
15,166 | public function template ( ) { return $ this -> entity -> template === 'custom' ? $ this -> entity -> custom_template : $ this -> entity -> template ; } | Get widget s view template . |
15,167 | public function class ( ) { $ repository = app ( 'extensions' ) ; $ extension = $ repository -> findOrFail ( $ this -> entity -> extension_id ) ; return $ extension -> param ( 'class' ) ; } | Get widget type FQCN . |
15,168 | public function create ( ) { $ permission = new Permission ; $ permission -> resource = 'System' ; $ roles = Role :: all ( ) ; return view ( 'administrator.permissions.create' , compact ( 'permission' , 'roles' ) ) ; } | Show permission form . |
15,169 | public function store ( ) { $ this -> validate ( $ this -> request , [ 'name' => 'required' , 'resource' => 'required|alpha_num' , 'slug' => 'required|unique:permissions,slug' , ] ) ; $ permission = Permission :: create ( $ this -> request -> all ( ) ) ; $ permission -> syncRoles ( $ this -> request -> get ( 'roles' , [ ] ) ) ; return redirect ( ) -> route ( 'administrator.permissions.index' ) ; } | Store a newly created permission . |
15,170 | public function storeResource ( ) { $ this -> validate ( $ this -> request , [ 'resource' => 'required|alpha_num' , ] ) ; $ permissions = Permission :: createResource ( $ this -> request -> resource ) ; foreach ( $ permissions as $ permission ) { $ permission -> syncRoles ( $ this -> request -> get ( 'roles' , [ ] ) ) ; } return redirect ( ) -> route ( 'administrator.permissions.index' ) ; } | Store permission resource . |
15,171 | public function update ( Permission $ permission ) { $ this -> validate ( $ this -> request , [ 'name' => 'required' , 'resource' => 'required|alpha_num' , 'slug' => 'required|unique:permissions,slug,' . $ permission -> id , ] ) ; $ permission -> name = $ this -> request -> get ( 'name' ) ; $ permission -> resource = $ this -> request -> get ( 'resource' ) ; if ( ! $ permission -> system ) { $ permission -> slug = $ this -> request -> get ( 'slug' ) ; } $ permission -> save ( ) ; $ permission -> syncRoles ( $ this -> request -> get ( 'roles' , [ ] ) ) ; return redirect ( ) -> route ( 'administrator.permissions.index' ) ; } | Update selected permission . |
15,172 | public function destroy ( Permission $ permission ) { if ( ! $ permission -> system ) { try { $ permission -> delete ( ) ; return $ this -> notifySuccess ( 'Permission successfully deleted!' ) ; } catch ( QueryException $ e ) { return $ this -> notifyError ( $ e -> getMessage ( ) ) ; } } return $ this -> notifyError ( 'System permission is protected and cannot be deleted!' ) ; } | Remove selected permission . |
15,173 | public static function fatorVencimento ( \ DateTime $ data ) { $ dataBase = new \ DateTime ( "1997-10-07" ) ; return ( int ) $ data -> diff ( $ dataBase , true ) -> format ( '%r%a' ) ; } | Calcula o fator vencimento . |
15,174 | public function index ( UsersDataTable $ dataTable ) { $ roles = $ this -> role -> pluck ( 'name' , 'id' ) ; return $ dataTable -> render ( 'administrator.users.index' , compact ( 'roles' ) ) ; } | Display list of users . |
15,175 | public function create ( ) { $ roles = $ this -> getAllowedRoles ( ) ; $ selectedRoles = $ this -> request -> old ( 'roles' ) ; $ user = new User ( [ 'blocked' => 0 , 'confirmed' => 1 , ] ) ; return view ( 'administrator.users.create' , compact ( 'user' , 'roles' , 'selectedRoles' ) ) ; } | Show user form . |
15,176 | protected function getAllowedRoles ( ) { if ( $ this -> request -> user ( 'administrator' ) -> isRole ( 'super-administrator' ) ) { $ roles = $ this -> role -> newQuery ( ) -> get ( ) ; } else { $ roles = $ this -> role -> newQuery ( ) -> where ( 'slug' , '!=' , 'super-administrator' ) -> get ( ) ; } return $ roles -> pluck ( 'name' , 'id' ) ; } | Get allowed roles for the current user . |
15,177 | public function store ( StoreUserValidator $ request ) { $ user = new User ( $ request -> all ( ) ) ; $ user -> password = bcrypt ( $ request -> get ( 'password' ) ) ; $ user -> is_activated = $ request -> get ( 'is_activated' , false ) ; $ user -> is_blocked = $ request -> get ( 'is_blocked' , false ) ; $ user -> is_admin = $ request -> get ( 'is_admin' , false ) ; $ user -> save ( ) ; $ user -> syncRoles ( $ request -> get ( 'roles' ) ) ; event ( new UserWasCreated ( $ user ) ) ; flash ( ) -> success ( 'User ' . $ user -> first_name . 'successfully created!' ) ; return redirect ( ) -> route ( 'administrator.users.index' ) ; } | Store a newly created user . |
15,178 | public function edit ( User $ user ) { $ roles = $ this -> getAllowedRoles ( ) ; $ selectedRoles = $ user -> roles ( ) -> pluck ( 'roles.id' ) ; return view ( 'administrator.users.edit' , compact ( 'user' , 'roles' , 'selectedRoles' ) ) ; } | Show and edit selected user . |
15,179 | public function destroy ( User $ user , $ force = false ) { if ( $ user -> id <> auth ( 'administrator' ) -> id ( ) ) { try { if ( $ force ) { $ user -> forceDelete ( ) ; } else { $ user -> delete ( ) ; } return $ this -> notifySuccess ( 'User successfully deleted!' ) ; } catch ( QueryException $ e ) { return $ this -> notifyError ( $ e -> getMessage ( ) ) ; } } return $ this -> notifyError ( 'You cannot delete your own record!' ) ; } | Remove selected user . |
15,180 | public function ban ( User $ user ) { $ user -> is_blocked = ! $ user -> is_blocked ; $ user -> save ( ) ; if ( $ user -> is_blocked ) { return $ this -> notifySuccess ( 'User ' . $ user -> name . ' blocked!' ) ; } else { return $ this -> notifySuccess ( 'User ' . $ user -> name . ' un-blocked!' ) ; } } | Toggle ban status of a user . |
15,181 | public function activate ( User $ user ) { $ user -> is_activated = ! $ user -> is_activated ; $ user -> save ( ) ; if ( $ user -> is_activated ) { return $ this -> notifySuccess ( 'User ' . $ user -> name . ' activated!' ) ; } else { return $ this -> notifySuccess ( 'User ' . $ user -> name . ' deactivated!' ) ; } } | Toggle user activation status . |
15,182 | public function updateAlerts ( & $ alerts ) { $ securityWarnings = $ this -> owner -> sourceRecords ( ) -> filter ( 'SecurityAlerts.ID:GreaterThan' , 0 ) ; if ( $ securityWarnings -> exists ( ) ) { $ alerts [ 'SecurityAlerts' ] = $ securityWarnings -> renderWith ( 'SecurityAlertSummary' ) ; } } | Update the Package s screen bound summary info with little badges to indicate security alerts are present for this package |
15,183 | public function show ( ) { $ keyword = request ( 'q' ) ; $ articles = [ ] ; $ limit = abs ( request ( 'limit' , config ( 'site.limit' , 10 ) ) ) ; $ max_limit = config ( 'site.max_limit' , 100 ) ; if ( $ limit > $ max_limit ) { $ limit = $ max_limit ; } if ( $ keyword ) { $ articles = $ this -> engine -> search ( $ keyword , $ limit ) ; $ articles -> appends ( 'q' , $ keyword ) ; $ articles -> appends ( 'limit' , $ limit ) ; } return view ( 'search.show' , compact ( 'articles' , 'keyword' ) ) ; } | Display search results . |
15,184 | public function create ( Widget $ widget ) { $ widget -> extension_id = old ( 'extension_id' , Extension :: WIDGET_WYSIWYG ) ; $ widget -> template = old ( 'template' , 'widgets.wysiwyg.raw' ) ; $ widget -> published = old ( 'published' , true ) ; return view ( 'administrator.widgets.create' , compact ( 'widget' ) ) ; } | Show widget form . |
15,185 | public function store ( WidgetFormRequest $ request ) { $ widget = new Widget ; $ widget -> fill ( $ request -> all ( ) ) ; $ widget -> published = $ request -> get ( 'published' , false ) ; $ widget -> authenticated = $ request -> get ( 'authenticated' , false ) ; $ widget -> show_title = $ request -> get ( 'show_title' , false ) ; $ widget -> save ( ) ; $ widget -> syncPermissions ( $ request -> get ( 'permissions' , [ ] ) ) ; $ widget -> syncMenuAssignment ( $ request -> get ( 'menu' , [ ] ) , $ request -> get ( 'assignment' , Widget :: ALL_PAGES ) ) ; flash ( ) -> success ( trans ( 'cms::widget.store.success' ) ) ; return redirect ( ) -> route ( 'administrator.widgets.index' ) ; } | Store a newly created widget . |
15,186 | public function edit ( Widget $ widget ) { $ widget -> type = old ( 'type' , $ widget -> type ) ; $ widget -> template = old ( 'template' , $ widget -> template ) ; return view ( 'administrator.widgets.edit' , compact ( 'widget' ) ) ; } | Show and edit selected widget . |
15,187 | public function templates ( $ type ) { $ data = [ ] ; $ extension = $ this -> repository -> findOrFail ( $ type ) ; foreach ( $ extension -> param ( 'templates' ) as $ template ) { $ data [ ] = [ 'key' => $ template [ 'path' ] , 'value' => $ template [ 'description' ] ] ; } return response ( ) -> json ( [ 'template' => $ data [ 0 ] [ 'key' ] , 'selected' => $ type , 'data' => $ data , ] , 200 ) ; } | Get all widget types . |
15,188 | public function parameters ( $ id , $ widget ) { $ widget = Widget :: withoutGlobalScope ( 'menu_assignment' ) -> findOrNew ( $ widget ) ; $ extension = $ this -> repository -> findOrFail ( $ id ) ; $ formView = $ extension -> param ( 'form' ) ; if ( view ( ) -> exists ( $ formView ) ) { return view ( $ formView , compact ( 'widget' ) ) ; } return view ( 'widgets.partials.none' ) ; } | Get widget custom parameter form if any . |
15,189 | public function createStylesheetPaths ( array $ stylesheets ) { $ sheets = array ( ) ; foreach ( $ stylesheets as $ key => $ sheet ) { if ( ! $ this -> isExternalStylesheet ( $ sheet ) ) { $ sheet = str_replace ( strrchr ( $ sheet , 'css?' ) , 'css' , $ sheet ) ; $ sheet = $ this -> getBasePath ( ) . $ sheet ; } $ sheets [ ] = $ sheet ; } return $ sheets ; } | Check if a stylesheet is a local stylesheet or an external stylesheet . If it is a local stylesheet prepend our basepath to the link so we can properly fetch the data to insert . |
15,190 | private function getStylesheetContent ( $ path ) { if ( $ this -> isExternalStylesheet ( $ path ) ) { $ cssData = $ this -> getRequestHandler ( ) -> getContent ( $ path ) ; } else { if ( file_exists ( $ path ) ) { $ cssData = file_get_contents ( $ path ) ; } else { return ; } } $ cssData = $ this -> replaceLocalUrlTags ( $ cssData ) ; return "<style type=\"text/css\">\n" . $ cssData . '</style>' ; } | Retrieve the contents from a CSS file . |
15,191 | public function actionForgottenPassword ( ) : void { $ session = $ this -> getSession ( 'cms/forgottenPassword' ) ; if ( $ session -> count >= self :: MAX_TRY ) { $ this -> flashNotifier -> warning ( 'cms.user.restorePasswordDisabledForHour' ) ; $ this -> redirect ( ":{$this->module}:Sign:in" ) ; } } | Obnoveni hesla je mozno jen trikrat do hodiny |
15,192 | public function signInFormSucceeded ( Form $ form , ArrayHash $ values ) { try { $ this -> user -> login ( $ values -> username , $ values -> password ) ; if ( $ values -> remember ) { $ this -> user -> setExpiration ( '+ ' . $ this -> sessionExpiration , false ) ; } else { $ this -> user -> setExpiration ( '+ ' . $ this -> loginExpiration , true ) ; } $ this -> restoreRequest ( $ this -> backlink ) ; $ this -> redirect ( ":{$this->module}:Homepage:" ) ; } catch ( AuthenticationException $ e ) { if ( $ e -> getCode ( ) == IAuthenticator :: NOT_APPROVED ) { $ form -> addError ( 'cms.user.accountDeactivated' ) ; } else { $ form -> addError ( 'cms.user.incorrectUsernameOrPassword' ) ; } } } | Zpracovani prihlasovaciho formulare |
15,193 | protected function createComponentForgottenPasswordForm ( ) : Form { $ form = $ this -> formFactory -> create ( ) ; $ form -> addProtection ( ) ; $ form -> addText ( 'usernameOrEmail' , 'cms.user.usernameOrEmail' ) -> setRequired ( ) ; $ form -> addSubmit ( 'send' , 'form.send' ) ; $ form -> addLink ( 'back' , 'form.back' , $ this -> link ( 'in' ) ) ; $ form -> onSuccess [ ] = [ $ this , 'forgottenPasswordFormSucceeded' ] ; return $ form ; } | Formular pro zapomenute heslo |
15,194 | public function forgottenPasswordFormSucceeded ( Form $ form , ArrayHash $ values ) : void { $ value = $ values -> usernameOrEmail ; $ user = $ this -> orm -> users -> getByUsername ( $ value ) ; if ( ! $ user ) { $ user = $ this -> orm -> users -> getByEmail ( $ value ) ; if ( ! $ user ) { $ form -> addError ( 'cms.user.incorrectUsernameOrEmail' ) ; $ session = $ this -> getSession ( 'cms/forgottenPassword' ) ; if ( isset ( $ session -> count ) ) { $ session -> count ++ ; } else { $ session -> setExpiration ( '1 hours' ) ; $ session -> count = 1 ; } $ this -> actionForgottenPassword ( ) ; return ; } } $ hash = $ this -> hasher -> hash ( Random :: generate ( ) ) ; $ session = $ this -> getSession ( 'cms/restorePassword' ) ; $ session -> setExpiration ( '1 hours' ) ; $ session -> $ hash = $ user -> email ; $ this -> mailer -> sendRestorePassword ( $ user -> email , $ hash ) ; $ this -> flashNotifier -> info ( 'cms.user.mailToRestorePasswordSent' ) ; $ this -> redirect ( ":{$this->module}:Sign:in" ) ; } | Zpracovani formulare pro zapomenute heslo |
15,195 | protected function createComponentRestorePasswordForm ( ) : Form { $ form = $ this -> formFactory -> create ( ) ; $ form -> addProtection ( ) ; $ form -> addHidden ( 'hash' ) ; $ form -> addPassword ( 'password' , 'cms.user.newPassword' ) -> setRequired ( ) -> addRule ( Form :: MIN_LENGTH , null , $ this -> minPasswordLength ) ; $ form -> addPassword ( 'passwordVerify' , 'cms.user.passwordVerify' ) -> setRequired ( ) -> addRule ( Form :: EQUAL , null , $ form [ 'password' ] ) ; $ form -> addSubmit ( 'restore' , 'form.save' ) ; $ form -> onSuccess [ ] = [ $ this , 'restorePasswordFormSucceeded' ] ; return $ form ; } | Formular pro obnoveni hesla |
15,196 | public function restorePasswordFormSucceeded ( Form $ form , ArrayHash $ values ) : void { $ session = $ this -> getSession ( 'cms/restorePassword' ) ; $ email = $ session -> { $ values -> hash } ; $ session -> remove ( ) ; $ user = $ this -> orm -> users -> getByEmail ( $ email ) ; if ( $ user ) { $ user -> setPassword ( $ values -> password ) ; $ this -> orm -> persistAndFlush ( $ user ) ; $ this -> flashNotifier -> success ( 'cms.user.passwordChanged' ) ; } else { $ this -> flashNotifier -> error ( 'cms.permissions.accessDenied' ) ; } $ this -> redirect ( ":{$this->module}:Sign:in" ) ; } | Zpracovani formulare pro obnoveni hesla |
15,197 | protected function createComponentRegisterAdministratorForm ( ) : Form { $ form = $ this -> formFactory -> create ( ) ; $ form -> addProtection ( ) ; $ form -> addText ( 'username' , 'cms.user.username' ) -> setRequired ( ) ; $ form -> addText ( 'firstName' , 'cms.user.firstName' ) ; $ form -> addText ( 'surname' , 'cms.user.surname' ) ; $ form -> addText ( 'email' , 'cms.user.email' ) -> setRequired ( ) -> addRule ( Form :: EMAIL ) ; $ form -> addPassword ( 'password' , 'cms.user.newPassword' ) -> setRequired ( ) -> addRule ( Form :: MIN_LENGTH , null , $ this -> minPasswordLength ) ; $ form -> addPassword ( 'passwordVerify' , 'cms.user.passwordVerify' ) -> setRequired ( ) -> addRule ( Form :: EQUAL , null , $ form [ 'password' ] ) ; $ form -> addSubmit ( 'create' , 'form.save' ) ; $ form -> onSuccess [ ] = [ $ this , 'registerAdministratorFormSucceeded' ] ; return $ form ; } | Formular pro prvniho uzivatele |
15,198 | public function registerAdministratorFormSucceeded ( Form $ form , ArrayHash $ values ) : void { $ password = $ values -> password ; $ role = $ this -> orm -> aclRoles -> getByName ( AclRolesMapper :: SUPERADMIN ) ; $ user = new User ; $ user -> firstName = $ values -> firstName ; $ user -> surname = $ values -> surname ; $ user -> email = $ values -> email ; $ user -> username = $ values -> username ; $ user -> setPassword ( $ password ) ; $ user -> roles -> add ( $ role ) ; $ this -> orm -> persistAndFlush ( $ user ) ; $ this -> user -> setExpiration ( '+ ' . $ this -> loginExpiration , true ) ; $ this -> user -> login ( $ values -> username , $ password ) ; $ this -> flashNotifier -> success ( 'cms.user.dataSaved' ) ; $ this -> redirect ( ":{$this->module}:Homepage:" ) ; } | Zpracovani formulare pro prvniho uzivatele |
15,199 | public function create ( MessageCreateEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { $ message = new MessageModel ( ) ; $ message -> setDispatcher ( $ dispatcher ) -> setName ( $ event -> getMessageName ( ) ) -> setLocale ( $ event -> getLocale ( ) ) -> setTitle ( $ event -> getTitle ( ) ) -> setSecured ( $ event -> getSecured ( ) ) -> save ( ) ; $ event -> setMessage ( $ message ) ; } | Create a new messageuration entry |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.