idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
20,800
public function withNameSpace ( $ namespace ) { $ namespace = ( string ) $ namespace ; if ( ! isset ( static :: $ namespaces [ $ namespace ] ) ) { $ new = clone $ this ; $ new -> setNamespace ( $ namespace ) ; $ new -> setEnabled ( $ this -> enabled ) ; static :: $ namespaces [ $ namespace ] = $ new ; } return static :: $ namespaces [ $ namespace ] ; }
Returns the instance with specified namespace .
20,801
public function setEnabled ( $ state = true ) { $ this -> enabled = ( bool ) $ state ; if ( $ this -> enabled ) { try { $ this -> createNamespace ( ) ; } catch ( Exception $ ex ) { throw new RuntimeException ( sprintf ( 'Failed to enable the cache adapter of class "%s" ' . 'with namespace "%s".' , static :: CLASS , $ this -> namespace ) , null , $ ex ) ; } } return $ this ; }
Sets the state of adapter to enabled state or to disabled state .
20,802
public function get ( $ key ) { if ( ! $ this -> enabled ) { return ; } $ file = $ this -> getPath ( $ key ) ; if ( ! file_exists ( $ file ) ) { return false ; } set_error_handler ( function ( ) { throw new Exception ( 'An error occurred.' ) ; } , E_WARNING ) ; try { if ( filemtime ( $ file ) < time ( ) ) { throw new Exception ( 'Term life data has expired.' ) ; } $ data = file_get_contents ( $ file ) ; } catch ( Exception $ ex ) { restore_error_handler ( ) ; $ this -> remove ( $ key ) ; return false ; } restore_error_handler ( ) ; return call_user_func ( $ this -> restoringFilter , $ data ) ; }
Gets a stored variable from the cache .
20,803
public function remove ( $ key ) { if ( ! $ this -> enabled ) { return ; } $ file = $ this -> getPath ( $ key ) ; if ( ! file_exists ( $ file ) ) { return true ; } set_error_handler ( function ( ) { throw new Exception ( 'An error occurred.' ) ; } , E_WARNING ) ; try { unlink ( $ file ) ; } catch ( Exception $ ex ) { restore_error_handler ( ) ; return false ; } restore_error_handler ( ) ; return true ; }
Removes a stored variable from the cache .
20,804
public function clearNamespace ( ) { if ( ! $ this -> enabled ) { return ; } $ error = false ; set_error_handler ( function ( ) use ( & $ error ) { $ error = true ; } , E_WARNING ) ; foreach ( glob ( $ this -> getPath ( ) . '/*.dat' ) as $ file ) { unlink ( $ file ) ; } restore_error_handler ( ) ; return ! $ error ; }
Cleans the namespace . Remove any previously stored for the current namespace .
20,805
public function clearExpired ( ) { if ( ! $ this -> enabled ) { return ; } $ error = false ; set_error_handler ( function ( ) use ( & $ error ) { $ error = true ; } , E_WARNING ) ; foreach ( glob ( $ this -> getPath ( ) . '/*.dat' ) as $ file ) { if ( filemtime ( $ file ) < time ( ) ) { unlink ( $ file ) ; } } restore_error_handler ( ) ; return ! $ error ; }
Cleans all expired variables .
20,806
protected function getPath ( $ variableName = '' ) { $ hash = function ( $ name ) { return hash ( $ this -> hashingAlgorithm , $ name ) ; } ; $ path = $ this -> basedir . PHP_DS . $ hash ( $ this -> namespace ) ; if ( $ variableName ) { $ path .= PHP_DS . $ hash ( $ variableName ) . '.dat' ; return $ path ; } return $ path ; }
Gets the path to the file appropriate variable or path to namespace directory .
20,807
protected function setDirPermissions ( $ permissions ) { $ permissions = ( int ) $ permissions ; if ( ! ( 0b100000000 & $ permissions ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid permissions "%s" for directories. ' . 'Directories will not available for reading.' , decoct ( $ permissions ) ) ) ; } if ( ! ( 0b010000000 & $ permissions ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid permissions "%s" for directories. ' . 'Directories will not available for writing.' , decoct ( $ permissions ) ) ) ; } if ( ! ( 0b001000000 & $ permissions ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid permissions "%s" for directories. ' . 'The content of directories will not available.' , decoct ( $ permissions ) ) ) ; } $ this -> dirPermissions = $ permissions ; }
Sets permissions for directories .
20,808
protected function setFilePermissions ( $ permissions ) { $ permissions = ( int ) $ permissions ; if ( ! ( 0b100000000 & $ permissions ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid permissions "%s" for files. ' . 'Files will not available for reading.' , decoct ( $ permissions ) ) ) ; } if ( ! ( 0b010000000 & $ permissions ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid permissions "%s" for files. ' . 'Files will not available for writing.' , decoct ( $ permissions ) ) ) ; } $ this -> filePermissions = $ permissions ; }
Sets permissions for files .
20,809
protected function createNamespace ( ) { $ dir = $ this -> getPath ( ) ; if ( ! file_exists ( $ dir ) || ! is_dir ( $ dir ) ) { set_error_handler ( function ( ) { throw new Exception ( 'An error occurred.' ) ; } , E_WARNING ) ; try { mkdir ( $ dir , $ this -> dirPermissions , true ) ; } catch ( Exception $ ex ) { restore_error_handler ( ) ; throw new RuntimeException ( sprintf ( 'Failed to create cache directory "%s".' , $ dir ) ) ; } restore_error_handler ( ) ; } if ( ! is_writable ( $ dir ) ) { throw new RuntimeException ( sprintf ( 'The cache directory "%s" is not writable.' , $ dir ) ) ; } if ( ! is_readable ( $ dir ) ) { throw new RuntimeException ( sprintf ( 'The cache directory "%s" is not readable.' , $ dir ) ) ; } }
Creates directory for current namespace if not exists .
20,810
public function load ( $ field , $ sourceUrl , $ idField = 'id' , $ textField = 'text' ) { if ( Str :: contains ( $ field , '.' ) ) { $ field = $ this -> formatName ( $ field ) ; $ class = str_replace ( [ '[' , ']' ] , '_' , $ field ) ; } else { $ class = $ field ; } $ script = <<<EOT$(document).on('change', "{$this->getElementClassSelector()}", function () { var target = $(this).closest('.fields-group').find(".$class"); $.get("$sourceUrl?q="+this.value, function (data) { target.find("option").remove(); $(target).select2({ data: $.map(data, function (d) { d.id = d.$idField; d.text = d.$textField; return d; }) }).trigger('change'); });});EOT ; Admin :: script ( $ script ) ; return $ this ; }
Load options for other select on change .
20,811
private static function getLooseIP ( ) : string { return md5 ( static :: $ tokenUseLooseIP && isset ( $ _SERVER [ 'REMOTE_ADDR' ] ) ? \ long2ip ( \ ip2long ( $ _SERVER [ 'REMOTE_ADDR' ] ) & \ ip2long ( '255.255.0.0' ) ) : '' ) ; }
Returns user s loose IP
20,812
private static function buildToken ( ) : string { return \ md5 ( \ sprintf ( 'MF_SESSION_INTEGRITY_TOKEN:%s%s%s%s%s%s' , static :: getLooseIP ( ) , static :: getHttpUserAgent ( ) , static :: getHttpAccept ( ) , static :: getHttpAcceptEncoding ( ) , static :: getHttpAcceptLanguage ( ) , static :: getHttpAcceptCharset ( ) ) ) ; }
Returns session integrity token based on session configuration
20,813
public static function setToken ( string $ variableName = '_MF_SESSION_INTEGRITY_TOKEN_' ) : bool { static :: init ( ) ; $ variableName = ( string ) $ variableName ; $ vHandler = Variables :: getInstance ( ) ; $ vHandler -> session -> set ( $ variableName , static :: buildToken ( ) ) ; return true ; }
Sets session integrity token according to session configuration
20,814
public static function check ( string $ variableName = '_MF_SESSION_INTEGRITY_TOKEN_' ) : bool { static :: init ( ) ; $ variableName = ( string ) $ variableName ; $ vHandler = Variables :: getInstance ( ) ; $ userToken = $ vHandler -> session -> get ( $ variableName , $ vHandler :: TYPE_STRING ) ; $ httpReferer = isset ( $ _SERVER [ 'HTTP_REFERER' ] ) ? $ _SERVER [ 'HTTP_REFERER' ] : '' ; $ rIntegrity = static :: $ refererIntegrityEnabled ? \ stripos ( $ httpReferer , static :: $ serverName ) !== false : true ; $ tIntegrity = static :: $ tokenIntegrityEnabled ? $ userToken === static :: buildToken ( ) : true ; return $ rIntegrity && $ tIntegrity ; }
Checks session integrity according to session configuration
20,815
public function setMetadata ( $ spec , $ value = null ) { if ( is_scalar ( $ spec ) ) { $ this -> metadata [ $ spec ] = $ value ; return $ this ; } if ( ! is_array ( $ spec ) && ! $ spec instanceof Traversable ) { throw new Exception \ InvalidArgumentException ( sprintf ( 'Expected a string, array, or Traversable argument in first position; received "%s"' , ( is_object ( $ spec ) ? get_class ( $ spec ) : gettype ( $ spec ) ) ) ) ; } foreach ( $ spec as $ key => $ value ) { $ this -> metadata [ $ key ] = $ value ; } return $ this ; }
Set message metadata
20,816
public function getMetadata ( $ key = null , $ default = null ) { if ( null === $ key ) { return $ this -> metadata ; } if ( ! is_scalar ( $ key ) ) { throw new Exception \ InvalidArgumentException ( 'Non-scalar argument provided for key' ) ; } if ( array_key_exists ( $ key , $ this -> metadata ) ) { return $ this -> metadata [ $ key ] ; } return $ default ; }
Retrieve all metadata or a single metadatum as specified by key
20,817
public function saveUser ( \ Native5 \ Services \ Users \ User $ user , $ updates ) { $ logger = $ GLOBALS [ 'logger' ] ; $ path = 'users/' . $ user -> getId ( ) ; $ request = $ this -> _remoteServer -> put ( $ path , array ( ) , json_encode ( $ updates ) ) ; try { $ response = $ request -> send ( ) ; return $ response -> getBody ( 'true' ) ; } catch ( \ Guzzle \ Http \ Exception \ BadResponseException $ e ) { $ logger -> info ( $ e -> getResponse ( ) -> getBody ( 'true' ) , array ( ) ) ; return false ; } }
Updates user details
20,818
public function verifyToken ( $ email , $ token ) { $ path = 'users/verify_token' ; $ request = $ this -> _remoteServer -> get ( $ path ) ; $ request -> getQuery ( ) -> set ( 'email' , $ email ) ; $ request -> getQuery ( ) -> set ( 'token' , $ token ) ; $ response = $ request -> send ( ) ; return $ response -> getBody ( 'true' ) ; }
Verifies token given the user id & the token .
20,819
public function createUser ( \ Native5 \ Services \ Users \ User $ user ) { global $ logger ; $ path = 'users/create' ; $ request = $ this -> _remoteServer -> post ( $ path ) -> setPostField ( 'username' , $ user -> getUsername ( ) ) -> setPostField ( 'password' , $ user -> getPassword ( ) ) -> setPostField ( 'name' , $ user -> getName ( ) ) -> setPostField ( 'roles' , json_encode ( $ user -> getRoles ( ) ) ) -> setPostField ( 'aliases' , json_encode ( $ user -> getAliases ( ) ) ) ; try { $ response = $ request -> send ( ) ; } catch ( \ Guzzle \ Http \ Exception \ BadResponseException $ e ) { $ logger -> info ( $ e -> getResponse ( ) -> getBody ( 'true' ) , array ( ) ) ; return false ; } return true ; }
createUser Create User for an application
20,820
public function getAllUsers ( $ count = 1000 , $ offset = 0 , $ searchToken = null ) { global $ logger ; $ path = 'users' ; $ request = $ this -> _remoteServer -> get ( $ path ) ; if ( ! empty ( $ searchToken ) ) { $ request -> getQuery ( ) -> set ( 'searchToken' , $ searchToken ) ; } $ request -> getQuery ( ) -> set ( 'numUsers' , $ count ) ; $ request -> getQuery ( ) -> set ( 'offset' , $ offset ) ; try { $ response = $ request -> send ( ) ; } catch ( \ Guzzle \ Http \ Exception \ BadResponseException $ e ) { $ logger -> info ( $ e -> getResponse ( ) -> getBody ( 'true' ) , array ( ) ) ; return false ; } return $ response -> json ( ) ; }
getAllUsers List all users for an application
20,821
public function getLayout ( ) { if ( ! $ this -> layout ) { $ layout = new ViewModel ( ) ; $ layout -> setTemplate ( 'layout/layout' ) ; $ this -> layout = $ layout ; } return $ this -> layout ; }
Gets the layout .
20,822
public function getEvents ( ) { if ( ! $ this -> events ) { $ services = $ this -> getServices ( ) ; $ events = $ services -> get ( 'Events' ) ; $ this -> setEvents ( $ events ) ; } return $ this -> events ; }
Gets the events .
20,823
public function render ( ViewModelInterface $ model ) { foreach ( $ model as $ child ) { $ groupId = $ child -> getGroupId ( ) ; if ( empty ( $ groupId ) ) { continue ; } $ result = $ this -> render ( $ child ) ; $ oldResult = $ model -> getVariable ( $ groupId , '' ) ; $ model -> setVariable ( $ groupId , $ oldResult . $ result ) ; } $ events = $ this -> getEvents ( ) ; $ event = new ViewEvent ( $ model ) ; $ events -> trigger ( $ event ) ; return $ event -> getResult ( ) ; }
Renders the view model .
20,824
public static function getLinkName ( $ issueLink ) { $ linkName = null ; if ( isset ( $ issueLink [ 'outwardIssue' ] ) ) { if ( isset ( $ issueLink [ 'outwardIssue' ] [ 'key' ] , $ issueLink [ 'type' ] [ 'outward' ] ) ) { $ linkName = $ issueLink [ 'type' ] [ 'outward' ] ; } } elseif ( isset ( $ issueLink [ 'inwardIssue' ] , $ issueLink [ 'type' ] [ 'inward' ] ) ) { if ( isset ( $ issueLink [ 'inwardIssue' ] [ 'key' ] ) ) { $ linkName = $ issueLink [ 'type' ] [ 'inward' ] ; } } return $ linkName ; }
Returns name of link from Issue link
20,825
public static function getLinkedIssueKey ( $ issueLink ) { $ linkedIssueKey = null ; if ( isset ( $ issueLink [ 'outwardIssue' ] ) ) { if ( isset ( $ issueLink [ 'outwardIssue' ] [ 'key' ] , $ issueLink [ 'type' ] [ 'outward' ] ) ) { $ linkedIssueKey = $ issueLink [ 'outwardIssue' ] [ 'key' ] ; } } elseif ( isset ( $ issueLink [ 'inwardIssue' ] , $ issueLink [ 'type' ] [ 'inward' ] ) ) { if ( isset ( $ issueLink [ 'inwardIssue' ] [ 'key' ] ) ) { $ linkedIssueKey = $ issueLink [ 'inwardIssue' ] [ 'key' ] ; } } return $ linkedIssueKey ; }
Returns key of linked Issue from Issue link
20,826
public function addItem ( MenuItem $ item ) { if ( $ item instanceof ResourceMenuItem ) { throw new \ InvalidArgumentException ( 'ResourceMenuItem passed to Resource::addItem(MenuItem). You cannot nest ResourceMenuItems.' ) ; } $ this -> items [ ] = $ item ; return $ this ; }
Adds a MenuItem which contains a database entry .
20,827
public function aujaSerialize ( ) { $ result = array ( ) ; $ result [ 'type' ] = $ this -> getType ( ) ; $ result [ $ this -> getType ( ) ] = $ this -> basicSerialize ( ) ; if ( $ this -> nextPageUrl != null || $ this -> totalPageUrl != null ) { $ result [ 'paging' ] = array ( ) ; if ( $ this -> nextPageUrl != null ) { $ result [ 'paging' ] [ 'next' ] = $ this -> nextPageUrl ; } if ( $ this -> totalPageUrl != null ) { $ result [ 'paging' ] [ 'total' ] = $ this -> totalPageUrl ; } } return $ result ; }
Overridden to add an extra paging section to the result .
20,828
protected function flow ( $ step ) { $ flow = router ( ) -> current ( ) -> parameter ( 'flow' ) ; if ( is_null ( $ flow ) ) { error ( 'Flow not information' ) ; } $ this -> model = call_user_func_array ( [ $ this -> modelName , 'find' ] , [ $ flow ] ) ; if ( is_null ( $ this -> model ) ) { error ( 'Flow "%s" not found' , $ flow ) ; } $ step = is_null ( $ step ) ? $ this -> model -> steps -> firstId ( ) : $ step ; if ( ! $ this -> model -> steps -> exists ( $ step ) ) { error ( 'Step "%s" not found' , $ step ) ; } $ this -> model -> steps -> setCurrent ( $ step ) ; return $ this -> model -> steps -> current ( ) ; }
Define com step atual e retornal o objeto .
20,829
public function createFlow ( ) { $ model = app ( $ this -> modelName ) ; $ model -> save ( ) ; $ step = $ model -> steps -> firstId ( ) ; return redirect ( ) -> route ( sprintf ( '%s.get' , $ this -> prefixRoute ) , [ 'flow' => $ model -> _id , 'step' => $ step ] ) ; }
Cria novo flow .
20,830
public function getSteps ( ) { $ step = $ this -> flow ( router ( ) -> current ( ) -> parameter ( 'step' ) ) ; $ view_id = sprintf ( '%s.%s' , $ this -> prefixViewName , $ step -> key ) ; if ( ! view ( ) -> exists ( $ view_id ) ) { error ( 'View of step "%s" not found' , $ view_id ) ; } $ view = view ( $ view_id ) ; $ view -> with ( 'steps' , $ this -> model -> steps ) ; $ view -> with ( 'step' , $ step ) ; $ view -> with ( 'model' , $ this -> model ) ; $ view -> with ( $ this -> viewParams ) ; $ view -> with ( 'step_url' , function ( $ step , $ method = 'get' ) { return $ this -> stepUrl ( $ step , $ method ) ; } ) ; return $ view ; }
Retorna a view do step .
20,831
protected function stepUrl ( Step $ step , $ method = 'get' ) { $ id = sprintf ( '%s.%s' , $ this -> prefixRoute , $ method ) ; return route ( $ id , [ 'step' => $ step -> key ] ) ; }
Retorna url do step .
20,832
public static function routesRegister ( Router $ router , $ prefixPart , $ routePrefix ) { $ class = get_called_class ( ) ; $ part = sprintf ( '%s' , $ prefixPart ) ; $ uses = sprintf ( '\%s@createFlow' , $ class ) ; $ as = sprintf ( '%s.create' , $ routePrefix ) ; $ router -> get ( $ part , [ 'uses' => $ uses , 'as' => $ as ] ) ; $ part = sprintf ( '%s/{flow}/{step}' , $ prefixPart ) ; $ uses = sprintf ( '\%s@getSteps' , $ class ) ; $ as = sprintf ( '%s.get' , $ routePrefix ) ; $ router -> get ( $ part , [ 'uses' => $ uses , 'as' => $ as ] ) ; $ part = sprintf ( '%s/{flow}' , $ prefixPart ) ; $ uses = sprintf ( '\%s@setSteps' , $ class ) ; $ as = sprintf ( '%s.post' , $ routePrefix ) ; $ router -> post ( $ part , [ 'uses' => $ uses , 'as' => $ as ] ) ; }
Register routes of flow .
20,833
public function resolve ( ) { $ resolve = parent :: resolve ( ) ; $ languages = Language :: getDb ( ) -> cache ( function ( $ db ) { return Language :: find ( ) -> where ( [ 'is_active' => true ] ) -> asArray ( ) -> all ( ) ; } ) ; Yii :: $ app -> params [ 'languages' ] = ArrayHelper :: map ( $ languages , 'code' , 'code' ) ; Yii :: $ app -> language = $ this -> getCurrentLang ( ) ; return $ resolve ; }
Resolve Resolves the current request into a route and the associated parameters . Sets default application language
20,834
protected function getCurrentLang ( ) { if ( ! Yii :: $ app -> user -> isGuest && ! empty ( Yii :: $ app -> user -> identity -> lang ) ) { $ lang = Yii :: $ app -> user -> identity -> lang ; } else if ( Yii :: $ app -> session -> get ( 'lang' ) ) { $ lang = Yii :: $ app -> session -> get ( 'lang' ) ; } else { $ lang = Yii :: $ app -> getRequest ( ) -> getPreferredLanguage ( ) ; } return $ lang ; }
Get current language If user is logged in gets its language Otherwise from session Otherwise from request
20,835
public function toRoute ( $ route ) { if ( $ this -> caller != null ) $ this -> disableRender [ ] = $ this -> caller -> identifier ; $ r = $ this -> router -> getRoute ( $ route ) ; if ( $ r != null ) { $ this -> currentRoute = $ r ; try { $ this -> execute ( ) ; } catch ( \ Exception $ e ) { Logger :: Log ( 'log/error.txt' , $ e -> getMessage ( ) ) ; \ decoy \ base \ ErrorController :: $ errors [ ] = $ e -> getMessage ( ) ; $ this -> toRoute ( 'error_page' ) ; } } $ this -> caller = null ; }
Redirecting the execution route . This will not change the URL . All the not fully executed instance will finish . If you dont t want that return after this method was called .
20,836
private function execute ( ) { if ( $ this -> currentRoute == null ) { $ this -> router -> getRoute ( 'error_page' ) -> setAction ( '_notFound' ) ; $ this -> toRoute ( 'error_page' ) ; return ; } $ controllerName = $ this -> currentRoute -> getController ( ) ; if ( $ controllerName == '' ) { if ( $ this -> currentRoute -> getParams ( ) != null && array_key_exists ( 'controller' , $ this -> currentRoute -> getParams ( ) ) ) $ controllerName = $ this -> currentRoute -> getParams ( ) [ 'controller' ] ; elseif ( $ this -> currentRoute -> getDefault ( ) != null ) $ controllerName = $ this -> currentRoute -> getDefault ( ) -> getController ( ) ; else { throw new \ Exception ( $ this -> translator -> translate ( "The requested url has a bad route configuration!" ) ) ; } } if ( array_key_exists ( $ controllerName , $ this -> invokable ) ) $ controllerName = $ this -> invokable [ $ controllerName ] ; elseif ( strpos ( $ controllerName , 'decoy\base' ) === false ) throw new \ Exception ( 'The requested Controller: \'' . $ controllerName . '\' is not registered!' ) ; $ c = new $ controllerName ( $ this ) ; if ( $ c -> getResult ( ) && ! in_array ( $ c -> identifier , $ this -> disableRender ) && $ this -> enableRender ) { echo $ this -> response -> output ( $ c ) ; } }
Executing the current route
20,837
private function parseRequestBody ( ) { $ content_type = $ this -> getRequestHeader ( ) -> getContentType ( ) ; if ( strpos ( $ content_type , 'application/json' ) !== false ) { $ this -> requestBody = new JsonBody ( ) ; } elseif ( strpos ( $ content_type , 'application/x-www-form-urlencoded' ) !== false ) { $ this -> requestBody = new FormBody ( ) ; } elseif ( strpos ( $ content_type , 'text/plain' ) !== false ) { $ this -> requestBody = new PlainBody ( ) ; } elseif ( strpos ( $ content_type , 'multipart/form-data' ) !== false ) { $ this -> requestBody = new MultipartBody ( ) ; } else { $ this -> requestBody = new HttpBody ( ) ; } }
Setting up the request body parser
20,838
private function getInvokablesFromModule ( array $ invokable ) { foreach ( $ invokable as $ key => $ path ) { $ this -> invokable [ $ key ] = $ path ; } }
Get all invokable from a module then assign it to a global list .
20,839
private function getViewsFromModule ( array $ views ) { foreach ( $ views as $ key => $ path ) $ this -> views [ $ key ] = $ path ; }
Get all view from a module then assign it to a global list .
20,840
public static function setDic ( DiC $ dic = null ) { if ( $ dic ) { static :: $ dic = $ dic ; } elseif ( ! static :: $ dic ) { static :: $ dic = new DiC ; static :: $ dic -> registerSingleton ( 'Fuel\\Dependency\\Container' , function ( $ container ) { static :: $ dic ; } ) ; } static :: $ dic -> registerSingleton ( 'dic' , function ( $ container ) { static :: $ dic ; } ) ; return static :: $ dic ; }
Sets the DiC
20,841
public function createService ( ServiceLocatorInterface $ serviceLocator ) { $ config = $ serviceLocator -> get ( 'Config' ) ; $ client = new Client ( ) ; if ( ! empty ( $ config [ $ this -> configKey ] ) ) { $ clientOptions = $ config [ $ this -> configKey ] ; if ( isset ( $ clientOptions [ 'uri' ] ) ) { $ client -> setUri ( $ clientOptions [ 'uri' ] ) ; unset ( $ clientOptions [ 'uri' ] ) ; } if ( isset ( $ clientOptions [ 'auth' ] ) ) { $ auth = $ clientOptions [ 'auth' ] ; $ client -> setAuth ( isset ( $ auth [ 'user' ] ) ? $ auth [ 'user' ] : '' , isset ( $ auth [ 'password' ] ) ? $ auth [ 'password' ] : '' , isset ( $ auth [ 'type' ] ) ? $ auth [ 'type' ] : $ client :: AUTH_BASIC ) ; unset ( $ clientOptions [ 'auth' ] ) ; } $ client -> setOptions ( $ config [ $ this -> configKey ] ) ; } return $ client ; }
Create a http client service
20,842
public static function enable ( interfaces \ handlers \ Error $ error = null , interfaces \ handlers \ Exception $ exception = null , $ threshold = null ) : bool { if ( static :: $ enabled ) { return false ; } static :: $ errorHandler = handlers \ Error :: register ( $ error , $ threshold ) ; static :: $ exceptionHandler = handlers \ Exception :: register ( $ exception ) ; return static :: $ enabled = true ; }
Enables the bundled Error and Exception Handlers by registering them with PHP .
20,843
public static function setDumper ( $ dumper ) { if ( ! $ dumper instanceof interfaces \ Dumper && ! is_callable ( $ dumper ) ) { throw new \ InvalidArgumentException ( 'Expected an instance of [' . interfaces \ Dumper :: class . '] or a callable, got [' . static :: getTypeName ( $ dumper ) . '] instead.' ) ; } static :: $ dumper = $ dumper ; }
Sets the Dumper to be used .
20,844
public function size ( $ width = null , $ height = null ) { foreach ( \ Config :: get ( 'flare-config.media.resize' ) as $ sizeArray ) { if ( $ width && $ height && ( $ width == $ sizeArray [ 0 ] ) && ( $ height == $ sizeArray [ 1 ] ) ) { return $ this -> path ? url ( 'uploads/media/' . $ sizeArray [ 0 ] . '-' . ( array_key_exists ( 1 , $ sizeArray ) ? $ sizeArray [ 1 ] : $ sizeArray [ 0 ] ) . '-' . $ this -> path ) : null ; } if ( $ width && ( $ width == $ sizeArray [ 0 ] ) ) { return $ this -> path ? url ( 'uploads/media/' . $ sizeArray [ 0 ] . '-' . ( array_key_exists ( 1 , $ sizeArray ) ? $ sizeArray [ 1 ] : $ sizeArray [ 0 ] ) . '-' . $ this -> path ) : null ; } } return $ this -> link ; }
Returns the media link in the requested size .
20,845
public function getHumanSizeAttribute ( ) { $ size = ( int ) $ this -> size ; if ( $ size >= 1 << 30 ) { return number_format ( $ size / ( 1 << 30 ) , 2 ) . 'GB' ; } if ( $ size >= 1 << 20 ) { return number_format ( $ size / ( 1 << 20 ) , 2 ) . 'MB' ; } if ( $ size >= 1 << 10 ) { return number_format ( $ size / ( 1 << 10 ) , 2 ) . 'KB' ; } return number_format ( $ size ) . ' bytes' ; }
Convert Media Size to a Human Readable Format .
20,846
public function index ( ) { $ models = $ this -> repository -> all ( [ ] , true ) ; app ( 'JavaScript' ) -> put ( 'models' , $ models ) ; return view ( 'attributes::admin.index-groups' ) ; }
List models .
20,847
public function checkForOpenRedirect ( $ urlForTestContents , $ testContents , $ useAsRegex = false ) { if ( \ count ( $ this -> openRedirectionURLs ) < 1 ) { return false ; } $ oldQuery = $ this -> query ; $ keys = \ array_keys ( $ this -> openRedirectionURLs ) ; foreach ( $ keys as $ key ) { $ this -> query [ $ key ] = $ urlForTestContents ; } \ stream_context_set_default ( array ( 'http' => array ( 'method' => 'HEAD' ) ) ) ; $ url = ( string ) $ this ; $ handleHeaders = true ; $ this -> query = $ oldQuery ; if ( false === ( $ headers = \ get_headers ( $ url , 1 ) ) ) { \ stream_context_set_default ( array ( 'http' => array ( 'method' => 'GET' ) ) ) ; if ( false === ( $ headers = \ get_headers ( $ url , 1 ) ) ) { $ handleHeaders = false ; } } else { \ stream_context_set_default ( array ( 'http' => array ( 'method' => 'GET' ) ) ) ; } if ( $ handleHeaders && \ count ( $ headers ) > 0 ) { $ headers = \ array_change_key_case ( $ headers , \ CASE_LOWER ) ; if ( isset ( $ headers [ 'location' ] ) && ( $ urlForTestContents === $ headers [ 'location' ] ) ) { return true ; } if ( isset ( $ headers [ 'refresh' ] ) && \ Niirrty \ strContains ( $ headers [ 'refresh' ] , $ urlForTestContents ) ) { return true ; } } $ resultContents = \ file_get_contents ( $ url ) ; if ( $ useAsRegex ) { try { return ( bool ) \ preg_match ( $ testContents , $ resultContents ) ; } catch ( \ Throwable $ ex ) { unset ( $ ex ) ; } } $ regex = '~<meta\s+http-equiv=(\'|")?refresh(\'|")?\s+content=(\'|")\d+;\s*url=' . \ preg_quote ( $ url ) . '~i' ; if ( \ preg_match ( $ regex , $ resultContents ) ) { return true ; } return $ testContents === $ resultContents ; }
Checks if possible open redirection bug URLs are defined if one of it its a real open redirection usage .
20,848
public function getScheme ( ) : string { if ( null === $ this -> scheme ) { $ this -> scheme = static :: $ fallbackScheme ; } return $ this -> scheme ; }
Gets the URL scheme . Default is http
20,849
public function setScheme ( ? string $ scheme = null ) : Url { if ( null === $ scheme || ! \ preg_match ( '~^[a-z]{3,7}$~i' , $ scheme ) ) { $ this -> scheme = 'http' ; return $ this ; } $ this -> scheme = $ scheme ; return $ this ; }
Sets the URL scheme . Default is http if none is defined
20,850
protected function mapConditionOperator ( $ operator ) { static $ specials = array ( 'BETWEEN' => array ( 'delimiter' => ' AND ' ) , 'IN' => array ( 'delimiter' => ', ' , 'prefix' => '(' , 'postfix' => ')' ) , 'NOT IN' => array ( 'delimiter' => ', ' , 'prefix' => '(' , 'postfix' => ')' ) , 'EXISTS' => array ( 'prefix' => '(' , 'postfix' => ')' ) , 'NOT EXISTS' => array ( 'prefix' => '(' , 'postfix' => ')' ) , 'IS NULL' => array ( 'use_value' => FALSE ) , 'IS NOT NULL' => array ( 'use_value' => FALSE ) , 'LIKE' => array ( 'postfix' => " ESCAPE '\\\\'" ) , 'NOT LIKE' => array ( 'postfix' => " ESCAPE '\\\\'" ) , '=' => array ( ) , '<' => array ( ) , '>' => array ( ) , '>=' => array ( ) , '<=' => array ( ) , ) ; if ( isset ( $ specials [ $ operator ] ) ) { $ return = $ specials [ $ operator ] ; } else { $ operator = strtoupper ( $ operator ) ; $ return = isset ( $ specials [ $ operator ] ) ? $ specials [ $ operator ] : array ( ) ; } $ return += array ( 'operator' => $ operator ) ; return $ return ; }
Gets any special processing requirements for the condition operator .
20,851
public function getResponse ( $ result ) { $ content = $ result -> getContent ( ) ; if ( $ result -> headers -> get ( 'content-type' ) == 'application/json' ) { $ content = json_decode ( $ result -> getContent ( ) , true ) ; } return array ( 'type' => 'rpc' , 'tid' => $ this -> tid , 'action' => $ this -> action , 'method' => $ this -> method , 'result' => $ content ) ; }
Return a result wrapper to ExtDirect method call .
20,852
public function getException ( $ exception ) { return array ( 'type' => 'exception' , 'tid' => $ this -> tid , 'action' => $ this -> action , 'method' => $ this -> method , 'message' => $ exception -> getMessage ( ) , 'where' => $ exception -> getTraceAsString ( ) ) ; }
Return an exception to ExtDirect call stack
20,853
private function initializeFromSingle ( $ call ) { $ this -> action = $ call [ 'action' ] ; $ this -> method = $ call [ 'method' ] ; $ this -> type = $ call [ 'type' ] ; $ this -> tid = $ call [ 'tid' ] ; $ this -> data = ( array ) $ call [ 'data' ] [ 0 ] ; }
Initialize the call properties from a single call .
20,854
private function initializeFromForm ( $ call ) { $ this -> action = $ call [ 'extAction' ] ; unset ( $ call [ 'extAction' ] ) ; $ this -> method = $ call [ 'extMethod' ] ; unset ( $ call [ 'extMethod' ] ) ; $ this -> type = $ call [ 'extType' ] ; unset ( $ call [ 'extType' ] ) ; $ this -> tid = $ call [ 'extTID' ] ; unset ( $ call [ 'extTID' ] ) ; $ this -> upload = $ call [ 'extUpload' ] ; unset ( $ call [ 'extUpload' ] ) ; foreach ( $ call as $ key => $ value ) { $ this -> data [ $ key ] = $ value ; } }
Initialize the call properties from a form call .
20,855
public function push ( string $ key , $ data , bool $ override = false ) { if ( ! array_key_exists ( $ key , $ this -> data ) || $ override ) { $ this -> data [ $ key ] = $ data ; return $ this -> data [ $ key ] ; } return false ; }
Pushs a value into the registry .
20,856
public function get ( string $ key ) { if ( array_key_exists ( $ key , $ this -> data ) ) { return $ this -> data [ $ key ] ; } return false ; }
Gets a value from the registry .
20,857
public static function encode ( $ value , $ ignore = null ) { if ( null === $ ignore ) { $ ignore = static :: CHAR_UNRESERVED . static :: CHAR_GEN_DELIMS . static :: CHAR_SUB_DELIMS ; } $ rawurlencode = function ( array $ matches ) { return rawurlencode ( $ matches [ 0 ] ) ; } ; return preg_replace_callback ( '/(?:[^' . $ ignore . '%]+|%(?![A-Fa-f0-9]{2}))/' , $ rawurlencode , $ value ) ; }
URI - encode according to RFC 3986 .
20,858
public function withPort ( $ port ) { $ new = clone $ this ; try { $ new -> setPort ( $ port ) ; } catch ( InvalidArgumentException $ ex ) { throw new InvalidArgumentException ( 'Invalid port provided.' , null , $ ex ) ; } return $ new ; }
Return an instance with the provided port . A null value provided for the port is equivalent to removing the port information .
20,859
public function withQuery ( $ query ) { $ new = clone $ this ; try { $ new -> setQuery ( $ query ) ; } catch ( InvalidArgumentException $ ex ) { throw new InvalidArgumentException ( 'Invalid query provided.' , null , $ ex ) ; } return $ new ; }
Return an instance with the provided query string .
20,860
protected function fromString ( $ uri ) { if ( ! is_string ( $ uri ) ) { throw new InvalidArgumentException ( sprintf ( '"%s()" expects string; "%s" received.' , __METHOD__ , is_object ( $ uri ) ? get_class ( $ uri ) : gettype ( $ uri ) ) ) ; } $ this -> setUserInfo ( parse_url ( $ uri , PHP_URL_USER ) , parse_url ( $ uri , PHP_URL_PASS ) ) -> setScheme ( parse_url ( $ uri , PHP_URL_SCHEME ) ) -> setHost ( parse_url ( $ uri , PHP_URL_HOST ) ) -> setPath ( parse_url ( $ uri , PHP_URL_PATH ) ) -> setQuery ( parse_url ( $ uri , PHP_URL_QUERY ) ) -> setFragment ( parse_url ( $ uri , PHP_URL_FRAGMENT ) ) ; if ( $ port = parse_url ( $ uri , PHP_URL_PORT ) ) { $ this -> setPort ( $ port ) ; } return $ this ; }
Forms the an object from an URI string .
20,861
protected function setScheme ( $ scheme ) { $ this -> uriString = null ; $ this -> scheme = strtolower ( rtrim ( $ scheme , ':/' ) ) ; return $ this ; }
Sets the URI scheme to current instance .
20,862
protected function setUserInfo ( $ user = '' , $ password = '' ) { $ this -> uriString = null ; if ( ! $ user ) { $ this -> userInfo = '' ; return $ this ; } $ this -> userInfo = rtrim ( $ user , '@' ) ; if ( $ password ) { $ this -> userInfo .= ':' . $ password ; } return $ this ; }
Sets the provided user information to current instance .
20,863
protected function setHost ( $ host ) { $ this -> uriString = null ; $ this -> host = ( string ) $ host ; return $ this ; }
Sets the provided host to current instance .
20,864
protected function setPort ( $ port ) { $ this -> uriString = null ; if ( null === $ port ) { $ this -> port = null ; return $ this ; } if ( ! $ this -> isPortValid ( $ port ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid port "%s" provided.' , ( is_object ( $ port ) ? get_class ( $ port ) : gettype ( $ port ) ) ) ) ; } $ this -> port = ( int ) $ port ; return $ this ; }
Sets the provided port to current instance .
20,865
protected function setPath ( $ path ) { $ this -> uriString = null ; $ path = ( string ) $ path ; if ( strpos ( $ path , '?' ) !== false ) { throw new InvalidArgumentException ( 'Invalid path provided; must not contain a query string.' ) ; } if ( strpos ( $ path , '#' ) !== false ) { throw new InvalidArgumentException ( 'Invalid path provided; must not contain a URI fragment.' ) ; } $ this -> path = static :: encode ( $ path ) ; return $ this ; }
Sets the provided path to current instance .
20,866
protected function setQuery ( $ query ) { $ this -> uriString = null ; $ query = ltrim ( $ query , '?' ) ; if ( strpos ( $ query , '#' ) !== false ) { throw new InvalidArgumentException ( 'Query string must not include a URI fragment.' ) ; } $ this -> query = static :: encode ( $ query ) ; return $ this ; }
Sets the provided query string to current instance .
20,867
protected function setFragment ( $ fragment ) { $ this -> uriString = null ; $ fragment = ltrim ( $ fragment , '#' ) ; $ this -> fragment = static :: encode ( $ fragment ) ; return $ this ; }
Sets the provided URI fragment to current instance .
20,868
public function theme ( ) { $ keys = [ 'Theme_id' ] ; $ ThemeSettings = $ this -> loadModel ( 'Wasabi/Cms.ThemeSettings' ) ; $ settings = $ ThemeSettings -> getKeyValues ( new GeneralSetting ( ) , $ keys ) ; if ( $ this -> request -> is ( 'post' ) && ! empty ( $ this -> request -> data ) ) { $ settings = $ ThemeSettings -> newEntity ( $ this -> request -> data ) ; if ( ! $ settings -> errors ( ) ) { if ( $ ThemeSettings -> saveKeyValues ( $ settings , $ keys ) ) { $ this -> Flash -> success ( __d ( 'wasabi_cms' , 'The theme settings have been updated.' ) ) ; $ this -> redirect ( [ 'action' => 'theme' ] ) ; return ; } else { $ this -> Flash -> error ( $ this -> dbErrorMessage ) ; } } else { $ this -> Flash -> error ( $ this -> formErrorMessage ) ; } } $ this -> set ( [ 'settings' => $ settings , 'themes' => ThemeManager :: getThemesForSelect ( ) ] ) ; }
theme action GET | POST
20,869
public function seo ( ) { $ keys = [ 'SEO__application-name' , 'SEO__google-site-verification' , 'SEO__meta-robots-index' , 'SEO__meta-robots-follow' , 'SEO__meta-robots-noodp' , 'SEO__display-search-box' , 'SEO__Social__facebook_url' , 'SEO__Social__facebook_page_id' , 'SEO__Social__twitter_username' , 'SEO__Social__instagram_url' , 'SEO__Social__linkedin_url' , 'SEO__Social__myspace_url' , 'SEO__Social__pinterest_url' , 'SEO__Social__youtube_url' , 'SEO__Social__googleplus_url' ] ; $ SeoSettings = $ this -> loadModel ( 'Wasabi/Cms.SeoSettings' ) ; $ settings = $ SeoSettings -> getKeyValues ( new GeneralSetting ( ) , $ keys ) ; if ( $ this -> request -> is ( 'post' ) && ! empty ( $ this -> request -> data ) ) { $ this -> request -> data [ 'SEO__Social__twitter_username' ] = ltrim ( trim ( $ this -> request -> data [ 'SEO__Social__twitter_username' ] ) , '@' ) ; $ settings = $ SeoSettings -> newEntity ( $ this -> request -> data ) ; if ( ! $ settings -> errors ( ) ) { if ( $ SeoSettings -> saveKeyValues ( $ settings , $ keys ) ) { $ this -> Flash -> success ( __d ( 'wasabi_cms' , 'The SEO settings have been updated.' ) ) ; $ this -> redirect ( [ 'action' => 'seo' ] ) ; return ; } else { $ this -> Flash -> error ( $ this -> dbErrorMessage ) ; } } else { $ this -> Flash -> error ( $ this -> formErrorMessage ) ; } } $ this -> set ( [ 'settings' => $ settings ] ) ; }
seo action GET | POST
20,870
public function open ( ) : string { if ( isset ( $ this -> config [ 'opener' ] ) ) { return $ this -> config [ 'opener' ] ; } $ this -> parsePrivateAttributes ( ) ; $ this -> parseCommonAttributes ( ) ; if ( isset ( $ this -> config [ 'in_scope' ] ) && isset ( $ this -> config [ 'scope_function' ] ) && is_callable ( $ this -> config [ 'scope_function' ] ) ) { $ this -> config [ 'scope_function' ] -> call ( $ this , $ this -> document -> scope ) ; } $ finisher = $ this -> isEmpty ? ' />' : '>' ; return "<{$this->tagName}{$this->attributesString}{$finisher}" ; }
Opening this tag node and returning node opener .
20,871
protected function sectionLedBy ( string $ leader , bool $ allowSpace = false ) : string { return $ this -> line -> pregGet ( ... [ ( '/ ' . preg_quote ( $ leader ) . ( $ allowSpace ? '((?!\()(?:[^ ]| (?=[a-zA-Z0-9]))+' : '([^ ]+' ) . '|(?<exp>\((?:[^()]+|(?&exp)?)+?\)))(?= |$)/' ) , 1 , ] ) ; }
Getting tag section with given leader .
20,872
private function setMultinameAttribute ( string $ name , string $ value , callable $ processer = null ) : self { if ( strlen ( $ value ) && ! empty ( $ this -> config [ $ name ] ) ) { return $ this -> setAttribute ( $ this -> config [ $ name ] , call_user_func ( $ processer ?? [ $ this , 'checkExpression' , ] , $ value ) ) ; } return $ this ; }
Setting attribute whitch has same name in HTSL but different name in HTML .
20,873
protected function checkExpression ( string $ value ) : string { return preg_match ( '/^\(.*\)$/' , $ value ) ? '<?=str_replace(\'"\',\'&quot;\',' . substr ( $ value , 1 , - 1 ) . ')?>' : str_replace ( '"' , '&quot;' , $ value ) ; }
Checking and parse PHP expressions .
20,874
protected function getAttributesString ( ) : string { ksort ( $ this -> attributes ) ; return implode ( '' , array_map ( static function ( string $ key , array $ data ) { return ( isset ( $ data [ 'condition' ] ) && strlen ( $ data [ 'condition' ] ) ? "<?php if( {$data['condition']} ){?> $key=\"{$data['value']}\"<?php }?>" : " $key=\"{$data['value']}\"" ) ; } , array_keys ( $ this -> attributes ) , $ this -> attributes ) ) ; }
Getting attribute string with HTML syntax .
20,875
protected function setAttribute ( string $ key , string $ value , string $ condition = null ) : self { if ( isset ( $ this -> attributes [ $ key ] ) ) { $ this -> document -> throw ( "Attribute $key of $this->name cannot redeclare." ) ; } $ this -> attributes [ $ key ] = [ 'value' => $ value , 'condition' => $ condition , ] ; return $ this ; }
Setting attribute .
20,876
public static function toCamelCase ( $ pStr , $ pCapitaliseFirstChar = true ) { if ( empty ( $ pStr ) ) { return $ pStr ; } $ pStr = strtolower ( $ pStr ) ; if ( $ pCapitaliseFirstChar ) { $ pStr [ 0 ] = strtoupper ( $ pStr [ 0 ] ) ; } return preg_replace_callback ( '/_([a-z])/' , function ( $ pMatches ) { return strtoupper ( $ pMatches [ 1 ] ) ; } , $ pStr ) ; }
Create a camel - case string .
20,877
public static function fromCamelCase ( $ pStr ) { if ( empty ( $ pStr ) ) { return $ pStr ; } $ pStr [ 0 ] = strtolower ( $ pStr [ 0 ] ) ; return preg_replace_callback ( '/([A-Z])/' , function ( $ pMatches ) { return '_' . strtolower ( $ pMatches [ 0 ] ) ; } , $ pStr ) ; }
Revert a camel - case .
20,878
public static function getRandomString ( $ pLength = 6 , $ pStrength = 1 ) { $ chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ; if ( $ pStrength >= 1 ) { $ chars .= '0123456789' ; } if ( $ pStrength >= 2 ) { $ strengthChars = '@#$%' ; $ chars .= $ strengthChars ; } $ str = '' ; for ( $ i = 0 ; $ i < $ pLength ; $ i ++ ) { $ str .= $ chars [ ( rand ( ) % strlen ( $ chars ) ) ] ; } if ( $ pStrength >= 2 and ! preg_match ( '/@|#|\$|%/' , $ str ) ) { $ str = substr ( $ str , 0 , - 1 ) ; $ str = preg_replace ( "/^(.{" . ( rand ( ) % $ pLength ) . "})/" , "$1" . $ strengthChars [ rand ( ) % strlen ( $ strengthChars ) ] , $ str ) ; } return $ str ; }
Return a random string with a variable length and strength .
20,879
public static function truncate ( $ pStr , $ pLimit , $ pEnd = '...' ) { $ str = strip_tags ( $ pStr ) ; $ length = mb_strlen ( $ str ) ; if ( $ length <= $ pLimit ) { return $ str ; } return trim ( mb_substr ( $ str , 0 , $ pLimit ) ) . $ pEnd ; }
Truncate a string and add an optional suffix .
20,880
public function get_data ( ) { $ settings = $ this -> get_settings ( ) [ $ this -> number ] ; return array_merge ( [ 'title' => $ settings [ 'title' ] ] , Acf :: get_widget_field ( $ this -> id ) ) ; }
Get the widget s data
20,881
public function messages ( $ name ) { if ( $ this -> hasMessagesFor ( $ name ) ) { foreach ( $ this -> getMessagesFor ( $ name ) as $ message ) { $ this -> flash -> error ( $ message ) ; } } }
Prints messages for a specific element
20,882
protected function _containerSetPath ( & $ container , $ path , $ value ) { $ path = $ this -> _normalizeArray ( $ path ) ; $ pathLength = count ( $ path ) ; if ( ! $ pathLength ) { throw $ this -> _createInvalidArgumentException ( $ this -> __ ( 'Path is empty' ) , null , null , $ container ) ; } if ( $ pathLength === 1 ) { $ this -> _containerSet ( $ container , $ path [ 0 ] , $ value ) ; return ; } $ currentSegment = array_shift ( $ path ) ; if ( is_array ( $ container ) ) { $ this -> _containerSetPath ( $ container [ $ currentSegment ] , $ path , $ value ) ; } else { $ childContainer = $ this -> _containerGet ( $ container , $ currentSegment ) ; $ this -> _containerSetPath ( $ childContainer , $ path , $ value ) ; } }
Sets data on the nested container .
20,883
public function BodyBox ( $ Column = 'Body' , $ Attributes = array ( ) ) { TouchValue ( 'MultiLine' , $ Attributes , TRUE ) ; TouchValue ( 'format' , $ Attributes , $ this -> GetValue ( 'Format' , C ( 'Garden.InputFormatter' ) ) ) ; TouchValue ( 'Wrap' , $ Attributes , TRUE ) ; TouchValue ( 'class' , $ Attributes , '' ) ; $ Attributes [ 'class' ] .= ' TextBox BodyBox' ; $ this -> SetValue ( 'Format' , $ Attributes [ 'format' ] ) ; $ this -> EventArguments [ 'Table' ] = GetValue ( 'Table' , $ Attributes ) ; $ this -> EventArguments [ 'Column' ] = $ Column ; $ this -> FireEvent ( 'BeforeBodyBox' ) ; return $ this -> TextBox ( $ Column , $ Attributes ) . $ this -> Hidden ( 'Format' ) ; }
A special text box for formattable text .
20,884
public function Button ( $ ButtonCode , $ Attributes = FALSE ) { $ Type = ArrayValueI ( 'type' , $ Attributes ) ; if ( $ Type === FALSE ) $ Type = 'submit' ; $ CssClass = ArrayValueI ( 'class' , $ Attributes ) ; if ( $ CssClass === FALSE ) $ Attributes [ 'class' ] = 'Button' ; $ Return = '<input type="' . $ Type . '"' ; $ Return .= $ this -> _IDAttribute ( $ ButtonCode , $ Attributes ) ; $ Return .= $ this -> _NameAttribute ( $ ButtonCode , $ Attributes ) ; $ Return .= ' value="' . T ( $ ButtonCode , ArrayValue ( 'value' , $ Attributes ) ) . '"' ; $ Return .= $ this -> _AttributesToString ( $ Attributes ) ; $ Return .= " />\n" ; return $ Return ; }
Returns XHTML for a button .
20,885
public function Calendar ( $ FieldName , $ Attributes = FALSE ) { $ Class = ArrayValueI ( 'class' , $ Attributes , FALSE ) ; if ( $ Class === FALSE ) $ Attributes [ 'class' ] = 'DateBox' ; return $ this -> Input ( $ FieldName , 'text' , $ Attributes ) ; }
Returns XHTML for a standard calendar input control .
20,886
public function CheckBox ( $ FieldName , $ Label = '' , $ Attributes = FALSE ) { $ Value = ArrayValueI ( 'value' , $ Attributes , true ) ; $ Attributes [ 'value' ] = $ Value ; if ( $ this -> GetValue ( $ FieldName ) == $ Value ) $ Attributes [ 'checked' ] = 'checked' ; $ ShowErrors = ( $ this -> _InlineErrors && array_key_exists ( $ FieldName , $ this -> _ValidationResults ) ) ; if ( $ ShowErrors ) $ this -> AddErrorClass ( $ Attributes ) ; $ Input = $ this -> Input ( $ FieldName , 'checkbox' , $ Attributes ) ; if ( $ Label != '' ) $ Input = '<label for="' . ArrayValueI ( 'id' , $ Attributes , $ this -> EscapeID ( $ FieldName , FALSE ) ) . '" class="CheckBoxLabel"' . Attribute ( 'title' , GetValue ( 'title' , $ Attributes ) ) . '>' . $ Input . ' ' . T ( $ Label ) . '</label>' ; if ( $ ShowErrors && ArrayValueI ( 'InlineErrors' , $ Attributes , TRUE ) ) $ Return .= $ this -> InlineError ( $ FieldName ) ; return $ Input ; }
Returns XHTML for a checkbox input element .
20,887
public function CheckBoxList ( $ FieldName , $ DataSet , $ ValueDataSet = NULL , $ Attributes = FALSE ) { $ Attributes [ 'InlineErrors' ] = FALSE ; $ Return = '' ; if ( $ this -> IsPostBack ( ) === FALSE ) { if ( $ ValueDataSet === NULL ) { $ CheckedValues = $ this -> GetValue ( $ FieldName ) ; } else { $ CheckedValues = $ ValueDataSet ; if ( is_object ( $ ValueDataSet ) ) $ CheckedValues = ConsolidateArrayValuesByKey ( $ ValueDataSet -> ResultArray ( ) , $ FieldName ) ; } } else { $ CheckedValues = $ this -> GetFormValue ( $ FieldName , array ( ) ) ; } $ i = 1 ; if ( is_object ( $ DataSet ) ) { $ ValueField = ArrayValueI ( 'ValueField' , $ Attributes , 'value' ) ; $ TextField = ArrayValueI ( 'TextField' , $ Attributes , 'text' ) ; foreach ( $ DataSet -> Result ( ) as $ Data ) { $ Instance = $ Attributes ; $ Instance = RemoveKeyFromArray ( $ Instance , array ( 'TextField' , 'ValueField' ) ) ; $ Instance [ 'value' ] = $ Data -> $ ValueField ; $ Instance [ 'id' ] = $ FieldName . $ i ; if ( is_array ( $ CheckedValues ) && in_array ( $ Data -> $ ValueField , $ CheckedValues ) ) { $ Instance [ 'checked' ] = 'checked' ; } $ Return .= '<li>' . $ this -> CheckBox ( $ FieldName . '[]' , $ Data -> $ TextField , $ Instance ) . "</li>\n" ; ++ $ i ; } } elseif ( is_array ( $ DataSet ) ) { foreach ( $ DataSet as $ Text => $ ID ) { $ Instance = $ Attributes ; $ Instance = RemoveKeyFromArray ( $ Instance , array ( 'TextField' , 'ValueField' ) ) ; $ Instance [ 'id' ] = $ FieldName . $ i ; if ( is_array ( $ ID ) ) { $ ValueField = ArrayValueI ( 'ValueField' , $ Attributes , 'value' ) ; $ TextField = ArrayValueI ( 'TextField' , $ Attributes , 'text' ) ; $ Text = GetValue ( $ TextField , $ ID , '' ) ; $ ID = GetValue ( $ ValueField , $ ID , '' ) ; } else { if ( is_numeric ( $ Text ) ) $ Text = $ ID ; } $ Instance [ 'value' ] = $ ID ; if ( is_array ( $ CheckedValues ) && in_array ( $ ID , $ CheckedValues ) ) { $ Instance [ 'checked' ] = 'checked' ; } $ Return .= '<li>' . $ this -> CheckBox ( $ FieldName . '[]' , $ Text , $ Instance ) . "</li>\n" ; ++ $ i ; } } return '<ul class="' . ConcatSep ( ' ' , 'CheckBoxList' , GetValue ( 'listclass' , $ Attributes ) ) . '">' . $ Return . '</ul>' ; }
Returns the XHTML for a list of checkboxes .
20,888
public function CheckBoxGrid ( $ FieldName , $ DataSet , $ ValueDataSet , $ Attributes ) { $ Attributes [ 'InlineErrors' ] = FALSE ; $ Return = '' ; $ CheckedValues = $ ValueDataSet ; if ( is_object ( $ ValueDataSet ) ) $ CheckedValues = ConsolidateArrayValuesByKey ( $ ValueDataSet -> ResultArray ( ) , $ FieldName ) ; $ i = 1 ; if ( is_object ( $ DataSet ) ) { $ ValueField = ArrayValueI ( 'ValueField' , $ Attributes , 'value' ) ; $ TextField = ArrayValueI ( 'TextField' , $ Attributes , 'text' ) ; $ LastGroup = '' ; $ Group = array ( ) ; $ Rows = array ( ) ; $ Cols = array ( ) ; $ CheckBox = '' ; foreach ( $ DataSet -> Result ( ) as $ Data ) { $ Instance = $ Attributes ; $ Instance = RemoveKeyFromArray ( $ Instance , array ( 'TextField' , 'ValueField' ) ) ; $ Instance [ 'value' ] = $ Data -> $ ValueField ; $ Instance [ 'id' ] = $ FieldName . $ i ; if ( is_array ( $ CheckedValues ) && in_array ( $ Data -> $ ValueField , $ CheckedValues ) ) { $ Instance [ 'checked' ] = 'checked' ; } $ CheckBox = $ this -> CheckBox ( $ FieldName . '[]' , '' , $ Instance ) ; $ CurrentTextField = $ Data -> $ TextField ; $ aCurrentTextField = explode ( '.' , $ CurrentTextField ) ; $ aCurrentTextFieldCount = count ( $ aCurrentTextField ) ; $ GroupName = array_shift ( $ aCurrentTextField ) ; $ ColName = array_pop ( $ aCurrentTextField ) ; if ( $ aCurrentTextFieldCount >= 3 ) { $ RowName = implode ( '.' , $ aCurrentTextField ) ; if ( $ GroupName != $ LastGroup && $ LastGroup != '' ) { $ Return .= $ this -> GetCheckBoxGridGroup ( $ LastGroup , $ Group , $ Rows , $ Cols ) ; $ Group = array ( ) ; $ Rows = array ( ) ; $ Cols = array ( ) ; } if ( array_key_exists ( $ ColName , $ Group ) === FALSE || is_array ( $ Group [ $ ColName ] ) === FALSE ) { $ Group [ $ ColName ] = array ( ) ; if ( ! in_array ( $ ColName , $ Cols ) ) $ Cols [ ] = $ ColName ; } if ( ! in_array ( $ RowName , $ Rows ) ) $ Rows [ ] = $ RowName ; $ Group [ $ ColName ] [ $ RowName ] = $ CheckBox ; $ LastGroup = $ GroupName ; } ++ $ i ; } } return $ Return . $ this -> GetCheckBoxGridGroup ( $ LastGroup , $ Group , $ Rows , $ Cols ) ; }
Returns the xhtml for a list of checkboxes ; sorted into groups related to the TextField value of the dataset .
20,889
public function Close ( $ ButtonCode = '' , $ Xhtml = '' , $ Attributes = FALSE ) { $ Return = "</div>\n</form>" ; if ( $ Xhtml != '' ) $ Return = $ Xhtml . $ Return ; if ( $ ButtonCode != '' ) $ Return = '<div class="Buttons">' . $ this -> Button ( $ ButtonCode , $ Attributes ) . '</div>' . $ Return ; return $ Return ; }
Returns the closing of the form tag with an optional submit button .
20,890
public function CurrentImage ( $ FieldName , $ Attributes = array ( ) ) { $ Result = $ this -> Hidden ( $ FieldName ) ; $ Value = $ this -> GetValue ( $ FieldName ) ; if ( $ Value ) { TouchValue ( 'class' , $ Attributes , 'CurrentImage' ) ; $ Result .= Img ( Gdn_Upload :: Url ( $ Value ) , $ Attributes ) ; } return $ Result ; }
Returns the current image in a field . This is meant to be used with image uploads so that users can see the current value .
20,891
public function DropDownGroup ( $ FieldName , $ Data , $ GroupField , $ TextField , $ ValueField , $ Attributes = array ( ) ) { $ Return = '<select' . $ this -> _IDAttribute ( $ FieldName , $ Attributes ) . $ this -> _NameAttribute ( $ FieldName , $ Attributes ) . $ this -> _AttributesToString ( $ Attributes ) . ">\n" ; $ CurrentValue = GetValue ( 'Value' , $ Attributes , FALSE ) ; if ( $ CurrentValue === FALSE ) $ CurrentValue = $ this -> GetValue ( $ FieldName , GetValue ( 'Default' , $ Attributes ) ) ; $ IncludeNull = ArrayValueI ( 'IncludeNull' , $ Attributes , FALSE ) ; if ( $ IncludeNull === TRUE ) $ Return .= "<option value=\"\"></option>\n" ; elseif ( $ IncludeNull ) $ Return .= "<option value=\"\">$IncludeNull</option>\n" ; $ LastGroup = NULL ; foreach ( $ Data as $ Row ) { $ Group = $ Row [ $ GroupField ] ; if ( $ LastGroup !== $ Group ) { if ( $ LastGroup !== NULL ) { $ Return .= '</optgroup>' ; } $ Return .= '<optgroup label="' . htmlspecialchars ( $ Group ) . "\">\n" ; $ LastGroup = $ Group ; } $ Value = $ Row [ $ ValueField ] ; if ( $ CurrentValue == $ Value ) { $ Selected = ' selected="selected"' ; } else $ Selected = '' ; $ Return .= '<option value="' . htmlspecialchars ( $ Value ) . '"' . $ Selected . '>' . htmlspecialchars ( $ Row [ $ TextField ] ) . "</option>\n" ; } if ( $ LastGroup ) $ Return .= '</optgroup>' ; $ Return .= '</select>' ; return $ Return ; }
Returns the xhtml for a dropdown list with option groups .
20,892
public function Errors ( ) { $ Return = '' ; if ( is_array ( $ this -> _ValidationResults ) && count ( $ this -> _ValidationResults ) > 0 ) { $ Return = "<div class=\"Messages Errors\">\n<ul>\n" ; foreach ( $ this -> _ValidationResults as $ FieldName => $ Problems ) { $ Count = count ( $ Problems ) ; for ( $ i = 0 ; $ i < $ Count ; ++ $ i ) { if ( substr ( $ Problems [ $ i ] , 0 , 1 ) == '@' ) $ Return .= '<li>' . substr ( $ Problems [ $ i ] , 1 ) . "</li>\n" ; else $ Return .= '<li>' . sprintf ( T ( $ Problems [ $ i ] ) , T ( $ FieldName ) ) . "</li>\n" ; } } $ Return .= "</ul>\n</div>\n" ; } return $ Return ; }
Returns XHTML for all form - related errors that have occurred .
20,893
public function EscapeString ( $ String ) { $ Array = FALSE ; if ( substr ( $ String , - 2 ) == '[]' ) { $ String = substr ( $ String , 0 , - 2 ) ; $ Array = TRUE ; } $ Return = urlencode ( str_replace ( ' ' , '_' , $ String ) ) ; if ( $ Array === TRUE ) $ Return .= '[]' ; return str_replace ( '.' , '-dot-' , $ Return ) ; }
Encodes the string in a php - form safe - encoded format .
20,894
public function GetCheckBoxGridGroup ( $ GroupName , $ Group , $ Rows , $ Cols ) { $ Return = '' ; $ Headings = '' ; $ Cells = '' ; $ RowCount = count ( $ Rows ) ; $ ColCount = count ( $ Cols ) ; for ( $ j = 0 ; $ j < $ RowCount ; ++ $ j ) { $ Alt = 1 ; for ( $ i = 0 ; $ i < $ ColCount ; ++ $ i ) { $ Alt = $ Alt == 0 ? 1 : 0 ; $ ColName = $ Cols [ $ i ] ; $ RowName = $ Rows [ $ j ] ; if ( $ j == 0 ) $ Headings .= '<td' . ( $ Alt == 0 ? ' class="Alt"' : '' ) . '>' . T ( $ ColName ) . '</td>' ; if ( array_key_exists ( $ RowName , $ Group [ $ ColName ] ) ) { $ Cells .= '<td' . ( $ Alt == 0 ? ' class="Alt"' : '' ) . '>' . $ Group [ $ ColName ] [ $ RowName ] . '</td>' ; } else { $ Cells .= '<td' . ( $ Alt == 0 ? ' class="Alt"' : '' ) . '>&#160;</td>' ; } } if ( $ Headings != '' ) $ Return .= "<thead><tr><th>" . T ( $ GroupName ) . "</th>" . $ Headings . "</tr></thead>\r\n<tbody>" ; $ aRowName = explode ( '.' , $ RowName ) ; $ RowNameCount = count ( $ aRowName ) ; if ( $ RowNameCount > 1 ) { $ RowName = '' ; for ( $ i = 0 ; $ i < $ RowNameCount ; ++ $ i ) { if ( $ i < $ RowNameCount - 1 ) $ RowName .= '<span class="Parent">' . T ( $ aRowName [ $ i ] ) . '</span>' ; else $ RowName .= T ( $ aRowName [ $ i ] ) ; } } else { $ RowName = T ( $ RowName ) ; } $ Return .= '<tr><th>' . $ RowName . '</th>' . $ Cells . "</tr>\r\n" ; $ Headings = '' ; $ Cells = '' ; } return $ Return == '' ? '' : '<table class="CheckBoxGrid">' . $ Return . '</tbody></table>' ; }
Returns a checkbox table .
20,895
public function GetHidden ( ) { $ Return = '' ; if ( is_array ( $ this -> HiddenInputs ) ) { foreach ( $ this -> HiddenInputs as $ Name => $ Value ) { $ Return .= $ this -> Hidden ( $ Name , array ( 'value' => $ Value ) ) ; } } return $ Return ; }
Returns XHTML for all hidden fields .
20,896
public function Hidden ( $ FieldName , $ Attributes = FALSE ) { $ Return = '<input type="hidden"' ; $ Return .= $ this -> _IDAttribute ( $ FieldName , $ Attributes ) ; $ Return .= $ this -> _NameAttribute ( $ FieldName , $ Attributes ) ; $ Return .= $ this -> _ValueAttribute ( $ FieldName , $ Attributes ) ; $ Return .= $ this -> _AttributesToString ( $ Attributes ) ; $ Return .= ' />' ; return $ Return ; }
Returns the xhtml for a hidden input .
20,897
public function ImageUpload ( $ FieldName , $ Attributes = array ( ) ) { $ Result = '<div class="FileUpload ImageUpload">' . $ this -> CurrentImage ( $ FieldName , $ Attributes ) . $ this -> Input ( $ FieldName . '_New' , 'file' ) . '</div>' ; return $ Result ; }
Return a control for uploading images .
20,898
public function InlineError ( $ FieldName ) { $ AppendError = '<p class="' . $ this -> ErrorClass . '">' ; foreach ( $ this -> _ValidationResults [ $ FieldName ] as $ ValidationError ) { $ AppendError .= sprintf ( T ( $ ValidationError ) , T ( $ FieldName ) ) . ' ' ; } $ AppendError .= '</p>' ; return $ AppendError ; }
Returns XHTML of inline error for specified field .
20,899
public function Input ( $ FieldName , $ Type = 'text' , $ Attributes = FALSE ) { if ( $ Type == 'text' || $ Type == 'password' ) { $ CssClass = ArrayValueI ( 'class' , $ Attributes ) ; if ( $ CssClass == FALSE ) $ Attributes [ 'class' ] = 'InputBox' ; } $ ShowErrors = $ this -> _InlineErrors && array_key_exists ( $ FieldName , $ this -> _ValidationResults ) ; if ( $ ShowErrors ) $ this -> AddErrorClass ( $ Attributes ) ; $ Return = '' ; $ Wrap = GetValue ( 'Wrap' , $ Attributes , FALSE , TRUE ) ; $ Strength = GetValue ( 'Strength' , $ Attributes , FALSE , TRUE ) ; if ( $ Wrap ) { $ Return .= '<div class="TextBoxWrapper">' ; } if ( strtolower ( $ Type ) == 'checkbox' ) { if ( isset ( $ Attributes [ 'nohidden' ] ) ) { unset ( $ Attributes [ 'nohidden' ] ) ; } else { $ Return .= '<input type="hidden" name="Checkboxes[]" value="' . ( substr ( $ FieldName , - 2 ) === '[]' ? substr ( $ FieldName , 0 , - 2 ) : $ FieldName ) . '" />' ; } } $ Return .= '<input type="' . $ Type . '"' ; $ Return .= $ this -> _IDAttribute ( $ FieldName , $ Attributes ) ; if ( $ Type == 'file' ) $ Return .= Attribute ( 'name' , ArrayValueI ( 'Name' , $ Attributes , $ FieldName ) ) ; else $ Return .= $ this -> _NameAttribute ( $ FieldName , $ Attributes ) ; if ( $ Strength ) $ Return .= ' data-strength="true"' ; $ Return .= $ this -> _ValueAttribute ( $ FieldName , $ Attributes ) ; $ Return .= $ this -> _AttributesToString ( $ Attributes ) ; $ Return .= ' />' ; if ( $ ShowErrors && ArrayValueI ( 'InlineErrors' , $ Attributes , TRUE ) ) $ Return .= $ this -> InlineError ( $ FieldName ) ; if ( $ Type == 'password' && $ Strength ) { $ Return .= <<<PASSWORDMETER<div class="PasswordStrength"> <div class="Background"></div> <div class="Strength"></div> <div class="Separator" style="left: 20%;"></div> <div class="Separator" style="left: 40%;"></div> <div class="Separator" style="left: 60%;"></div> <div class="Separator" style="left: 80%;"></div> <div class="StrengthText">&nbsp;</div></div>PASSWORDMETER ; } if ( $ Wrap ) $ Return .= '</div>' ; return $ Return ; }
Returns the xhtml for a standard input tag .