idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
4,200 | protected function redirectToSuccess ( array $ data ) { $ link = $ this -> link ( 'passwordsent' ) ; return $ this -> redirect ( $ this -> addBackURLParam ( $ link ) ) ; } | Avoid information disclosure by displaying the same status regardless wether the email address actually exists |
4,201 | public function unshift ( $ key , $ value ) { $ oldItems = $ this -> firstItems ; $ this -> firstItems = array ( $ key => $ value ) ; if ( $ oldItems ) { $ this -> firstItems = $ this -> firstItems + $ oldItems ; } return $ this ; } | Unshift an item onto the start of the map . |
4,202 | public function push ( $ key , $ value ) { $ oldItems = $ this -> lastItems ; $ this -> lastItems = array ( $ key => $ value ) ; if ( $ oldItems ) { $ this -> lastItems = $ this -> lastItems + $ oldItems ; } return $ this ; } | Pushes an item onto the end of the map . |
4,203 | public function getIterator ( ) { return new Map_Iterator ( $ this -> list -> getIterator ( ) , $ this -> keyField , $ this -> valueField , $ this -> firstItems , $ this -> lastItems ) ; } | Returns an Map_Iterator instance for iterating over the complete set of items in the map . |
4,204 | protected function getNameFromParent ( ) { $ base = $ this -> gridField ; $ name = array ( ) ; do { array_unshift ( $ name , $ base -> getName ( ) ) ; $ base = $ base -> getForm ( ) ; } while ( $ base && ! ( $ base instanceof Form ) ) ; return implode ( '.' , $ name ) ; } | Calculate the name of the gridfield relative to the form . |
4,205 | protected function getAuthenticator ( $ name = 'default' ) { $ authenticators = $ this -> authenticators ; if ( isset ( $ authenticators [ $ name ] ) ) { return $ authenticators [ $ name ] ; } throw new LogicException ( 'No valid authenticator found' ) ; } | Get the selected authenticator for this request |
4,206 | public function getApplicableAuthenticators ( $ service = Authenticator :: LOGIN ) { $ authenticators = $ this -> getAuthenticators ( ) ; foreach ( $ authenticators as $ name => $ authenticator ) { if ( ! ( $ authenticator -> supportedServices ( ) & $ service ) ) { unset ( $ authenticators [ $ name ] ) ; } } if ( empty... | Get all registered authenticators |
4,207 | public function getLoginForms ( ) { Deprecation :: notice ( '5.0.0' , 'Now handled by delegateToMultipleHandlers' ) ; return array_map ( function ( Authenticator $ authenticator ) { return [ $ authenticator -> getLoginHandler ( $ this -> Link ( ) ) -> loginForm ( ) ] ; } , $ this -> getApplicableAuthenticators ( ) ) ; ... | Get the login forms for all available authentication methods |
4,208 | public function Link ( $ action = null ) { $ link = Controller :: join_links ( Director :: baseURL ( ) , "Security" , $ action ) ; $ this -> extend ( 'updateLink' , $ link , $ action ) ; return $ link ; } | Get a link to a security action |
4,209 | protected function preLogin ( ) { $ eventResults = $ this -> extend ( 'onBeforeSecurityLogin' ) ; if ( $ this -> redirectedTo ( ) ) { return $ this -> getResponse ( ) ; } if ( $ eventResults ) { foreach ( $ eventResults as $ result ) { if ( $ result instanceof HTTPResponse ) { return $ result ; } } } if ( ! $ this -> g... | Perform pre - login checking and prepare a response if available prior to login |
4,210 | protected function getResponseController ( $ title ) { $ pageClass = $ this -> config ( ) -> get ( 'page_class' ) ; if ( ! $ pageClass || ! class_exists ( $ pageClass ) ) { return $ this ; } $ holderPage = Injector :: inst ( ) -> create ( $ pageClass ) ; $ holderPage -> Title = $ title ; $ holderPage -> URLSegment = 'S... | Prepare the controller for handling the response to this request |
4,211 | protected function generateTabbedFormSet ( $ forms ) { if ( count ( $ forms ) === 1 ) { return $ forms ; } $ viewData = new ArrayData ( [ 'Forms' => new ArrayList ( $ forms ) , ] ) ; return $ viewData -> renderWith ( $ this -> getTemplatesFor ( 'MultiAuthenticatorTabbedForms' ) ) ; } | Combine the given forms into a formset with a tabbed interface |
4,212 | public function setSessionMessage ( $ message , $ messageType = ValidationResult :: TYPE_WARNING , $ messageCast = ValidationResult :: CAST_TEXT ) { Controller :: curr ( ) -> getRequest ( ) -> getSession ( ) -> set ( "Security.Message.message" , $ message ) -> set ( "Security.Message.type" , $ messageType ) -> set ( "S... | Set the next message to display for the security login page . Defaults to warning |
4,213 | public function logout ( $ request = null , $ service = Authenticator :: LOGOUT ) { $ authName = null ; if ( ! $ request ) { $ request = $ this -> getRequest ( ) ; } $ handlers = $ this -> getServiceAuthenticatorsFromRequest ( $ service , $ request ) ; $ link = $ this -> Link ( 'logout' ) ; array_walk ( $ handlers , fu... | Log the currently logged in user out |
4,214 | protected function getServiceAuthenticatorsFromRequest ( $ service , HTTPRequest $ request ) { $ authName = null ; if ( $ request -> param ( 'ID' ) ) { $ authName = $ request -> param ( 'ID' ) ; } if ( $ authName && $ this -> hasAuthenticator ( $ authName ) ) { if ( $ request ) { $ request -> shift ( ) ; } $ authentica... | Get authenticators for the given service optionally filtered by the ID parameter of the current request |
4,215 | protected function aggregateTabbedForms ( array $ results ) { $ forms = [ ] ; foreach ( $ results as $ authName => $ singleResult ) { if ( ! is_array ( $ singleResult ) || ! isset ( $ singleResult [ 'Form' ] ) ) { user_error ( 'Authenticator "' . $ authName . '" doesn\'t support tabbed forms' , E_USER_WARNING ) ; conti... | Aggregate tabbed forms from each handler to fragments ready to be rendered . |
4,216 | protected function delegateToMultipleHandlers ( array $ handlers , $ title , array $ templates , callable $ aggregator ) { if ( count ( $ handlers ) === 1 ) { return $ this -> delegateToHandler ( array_values ( $ handlers ) [ 0 ] , $ title , $ templates ) ; } $ results = array_map ( function ( RequestHandler $ handler ... | Delegate to a number of handlers and aggregate the results . This is used for example to build the log - in page where there are multiple authenticators active . |
4,217 | protected function delegateToHandler ( RequestHandler $ handler , $ title , array $ templates = [ ] ) { $ result = $ handler -> handleRequest ( $ this -> getRequest ( ) ) ; if ( is_array ( $ result ) ) { $ result = $ this -> renderWrappedController ( $ title , $ result , $ templates ) ; } return $ result ; } | Delegate to another RequestHandler rendering any fragment arrays into an appropriate . controller . |
4,218 | protected function renderWrappedController ( $ title , array $ fragments , array $ templates ) { $ controller = $ this -> getResponseController ( $ title ) ; if ( ( $ response = $ controller -> getResponse ( ) ) && $ response -> isFinished ( ) ) { return $ response ; } $ messageType = '' ; $ message = $ this -> getSess... | Render the given fragments into a security page controller with the given title . |
4,219 | public function lostpassword ( ) { $ handlers = [ ] ; $ authenticators = $ this -> getApplicableAuthenticators ( Authenticator :: RESET_PASSWORD ) ; foreach ( $ authenticators as $ authenticator ) { $ handlers [ ] = $ authenticator -> getLostPasswordHandler ( Controller :: join_links ( $ this -> Link ( ) , 'lostpasswor... | Show the lost password page |
4,220 | public function getTemplatesFor ( $ action ) { $ templates = SSViewer :: get_templates_by_class ( static :: class , "_{$action}" , __CLASS__ ) ; return array_merge ( $ templates , [ "Security_{$action}" , "Security" , $ this -> config ( ) -> get ( "template_main" ) , "BlankPage" ] ) ; } | Determine the list of templates to use for rendering the given action . |
4,221 | public static function setDefaultAdmin ( $ username , $ password ) { Deprecation :: notice ( '5.0.0' , 'Please use DefaultAdminService::setDefaultAdmin($username, $password)' ) ; DefaultAdminService :: setDefaultAdmin ( $ username , $ password ) ; return true ; } | Set a default admin in dev - mode |
4,222 | public static function logout_url ( ) { $ logoutUrl = Controller :: join_links ( Director :: baseURL ( ) , self :: config ( ) -> get ( 'logout_url' ) ) ; return SecurityToken :: inst ( ) -> addToUrl ( $ logoutUrl ) ; } | Get the URL of the logout page . |
4,223 | public function setValue ( $ value , $ obj = null ) { if ( $ obj instanceof DataObject ) { $ this -> loadFrom ( $ obj ) ; } else { parent :: setValue ( $ value ) ; } return $ this ; } | Load a value into this MultiSelectField |
4,224 | public function loadFrom ( DataObjectInterface $ record ) { $ fieldName = $ this -> getName ( ) ; if ( empty ( $ fieldName ) || empty ( $ record ) ) { return ; } $ relation = $ record -> hasMethod ( $ fieldName ) ? $ record -> $ fieldName ( ) : null ; if ( $ relation instanceof Relation ) { $ value = array_values ( $ r... | Load the value from the dataobject into this field |
4,225 | protected function stringDecode ( $ value ) { if ( empty ( $ value ) ) { return array ( ) ; } $ result = json_decode ( $ value , true ) ; if ( $ result !== false ) { return $ result ; } throw new \ InvalidArgumentException ( "Invalid string encoded value for multi select field" ) ; } | Extract a string value into an array of values |
4,226 | protected function csvEncode ( $ value ) { if ( ! $ value ) { return null ; } return implode ( ',' , array_map ( function ( $ x ) { return str_replace ( ',' , '' , $ x ) ; } , array_values ( $ value ) ) ) ; } | Encode a list of values into a string as a comma separated list . Commas will be stripped from the items passed in |
4,227 | public function getItemPath ( $ class ) { foreach ( array_reverse ( $ this -> manifests ) as $ manifest ) { $ manifestInst = $ manifest [ 'instance' ] ; if ( $ path = $ manifestInst -> getItemPath ( $ class ) ) { return $ path ; } if ( $ manifest [ 'exclusive' ] ) { break ; } } return false ; } | Returns the path for a class or interface in the currently active manifest or any previous ones if later manifests aren t set to exclusive . |
4,228 | public function init ( $ includeTests = false , $ forceRegen = false ) { foreach ( $ this -> manifests as $ manifest ) { $ instance = $ manifest [ 'instance' ] ; $ instance -> init ( $ includeTests , $ forceRegen ) ; } $ this -> registerAutoloader ( ) ; } | Initialise the class loader |
4,229 | public static function check ( $ code , $ arg = "any" , $ member = null , $ strict = true ) { if ( ! $ member ) { if ( ! Security :: getCurrentUser ( ) ) { return false ; } $ member = Security :: getCurrentUser ( ) ; } return self :: checkMember ( $ member , $ code , $ arg , $ strict ) ; } | Check that the current member has the given permission . |
4,230 | public static function permissions_for_member ( $ memberID ) { $ groupList = self :: groupList ( $ memberID ) ; if ( $ groupList ) { $ groupCSV = implode ( ", " , $ groupList ) ; $ allowed = array_unique ( DB :: query ( " SELECT \"Code\" FROM \"Permission\" WHERE \"Type\" = " . self :: GRANT_PERMISSION . " AND... | Get all the any permission codes available to the given member . |
4,231 | public static function groupList ( $ memberID = null ) { if ( ! $ memberID ) { $ member = Security :: getCurrentUser ( ) ; if ( $ member && isset ( $ _SESSION [ 'Permission_groupList' ] [ $ member -> ID ] ) ) { return $ _SESSION [ 'Permission_groupList' ] [ $ member -> ID ] ; } } else { $ member = DataObject :: get_by_... | Get the list of groups that the given member belongs to . |
4,232 | public static function get_members_by_permission ( $ code ) { $ toplevelGroups = self :: get_groups_by_permission ( $ code ) ; if ( ! $ toplevelGroups ) { return new ArrayList ( ) ; } $ groupIDs = array ( ) ; foreach ( $ toplevelGroups as $ group ) { $ familyIDs = $ group -> collateFamilyIDs ( ) ; if ( is_array ( $ fam... | Returns all members for a specific permission . |
4,233 | public static function get_groups_by_permission ( $ codes ) { $ codeParams = is_array ( $ codes ) ? $ codes : array ( $ codes ) ; $ codeClause = DB :: placeholders ( $ codeParams ) ; return Group :: get ( ) -> where ( array ( "\"PermissionRoleCode\".\"Code\" IN ($codeClause) OR \"Permission\".\"Code\" IN ($codeClause)"... | Return all of the groups that have one of the given permission codes |
4,234 | public static function sort_permissions ( $ a , $ b ) { if ( $ a [ 'sort' ] == $ b [ 'sort' ] ) { return strcmp ( $ a [ 'name' ] , $ b [ 'name' ] ) ; } else { return $ a [ 'sort' ] < $ b [ 'sort' ] ? - 1 : 1 ; } } | Sort permissions based on their sort value or name |
4,235 | public static function get_declared_permissions_list ( ) { if ( ! self :: $ declared_permissions ) { return null ; } if ( self :: $ declared_permissions_list ) { return self :: $ declared_permissions_list ; } self :: $ declared_permissions_list = array ( ) ; self :: traverse_declared_permissions ( self :: $ declared_pe... | Get a linear list of the permissions in the system . |
4,236 | protected static function traverse_declared_permissions ( $ declared , & $ list ) { if ( ! is_array ( $ declared ) ) { return ; } foreach ( $ declared as $ perm => $ value ) { if ( $ value instanceof Permission_Group ) { $ list [ ] = $ value -> getName ( ) ; self :: traverse_declared_permissions ( $ value -> getPermiss... | Recursively traverse the nested list of declared permissions and create a linear list . |
4,237 | public function getComponentsByType ( $ type ) { $ components = new ArrayList ( ) ; foreach ( $ this -> components as $ component ) { if ( $ component instanceof $ type ) { $ components -> push ( $ component ) ; } } return $ components ; } | Returns all components extending a certain class or implementing a certain interface . |
4,238 | public function getComponentByType ( $ type ) { foreach ( $ this -> components as $ component ) { if ( $ component instanceof $ type ) { return $ component ; } } return null ; } | Returns the first available component with the given class or interface . |
4,239 | public function validate ( ) { $ this -> resetResult ( ) ; if ( $ this -> getEnabled ( ) ) { $ this -> php ( $ this -> form -> getData ( ) ) ; } return $ this -> result ; } | Returns any errors there may be . |
4,240 | public static function handle_shortcode ( $ arguments , $ content , $ parser , $ shortcode , $ extra = array ( ) ) { if ( ! empty ( $ content ) ) { $ serviceURL = $ content ; } elseif ( ! empty ( $ arguments [ 'url' ] ) ) { $ serviceURL = $ arguments [ 'url' ] ; } else { return '' ; } $ serviceArguments = [ ] ; if ( ! ... | Embed shortcode parser from Oembed . This is a temporary workaround . Oembed class has been replaced with the Embed external service . |
4,241 | protected static function videoEmbed ( $ arguments , $ content ) { if ( ! empty ( $ arguments [ 'width' ] ) ) { $ arguments [ 'style' ] = 'width: ' . intval ( $ arguments [ 'width' ] ) . 'px;' ; } if ( ! empty ( $ arguments [ 'caption' ] ) ) { $ xmlCaption = Convert :: raw2xml ( $ arguments [ 'caption' ] ) ; $ content ... | Build video embed tag |
4,242 | public function getSchemaDataDefaults ( ) { $ defaults = parent :: getSchemaDataDefaults ( ) ; $ children = $ this -> getChildren ( ) ; if ( $ children && $ children -> count ( ) ) { $ childSchema = [ ] ; foreach ( $ children as $ child ) { $ childSchema [ ] = $ child -> getSchemaData ( ) ; } $ defaults [ 'children' ] ... | Merge child field data into this form |
4,243 | public function collateDataFields ( & $ list , $ saveableOnly = false ) { foreach ( $ this -> children as $ field ) { if ( ! $ field instanceof FormField ) { continue ; } if ( $ field instanceof CompositeField ) { $ field -> collateDataFields ( $ list , $ saveableOnly ) ; } if ( $ saveableOnly ) { $ isIncluded = ( $ fi... | Add all of the non - composite fields contained within this field to the list . |
4,244 | public function makeFieldReadonly ( $ field ) { $ fieldName = ( $ field instanceof FormField ) ? $ field -> getName ( ) : $ field ; foreach ( $ this -> children as $ i => $ item ) { if ( $ item instanceof CompositeField ) { if ( $ item -> makeFieldReadonly ( $ fieldName ) ) { return true ; } ; } elseif ( $ item instanc... | Transform the named field into a readonly feld . |
4,245 | public function renameTable ( $ old , $ new ) { $ this -> replaceText ( "`$old`" , "`$new`" ) ; $ this -> replaceText ( "\"$old\"" , "\"$new\"" ) ; $ this -> replaceText ( Convert :: symbol2sql ( $ old ) , Convert :: symbol2sql ( $ new ) ) ; } | Swap the use of one table with another . |
4,246 | public function sql ( & $ parameters = array ( ) ) { $ sql = DB :: build_sql ( $ this , $ parameters ) ; if ( empty ( $ sql ) ) { return null ; } if ( $ this -> replacementsOld ) { $ sql = str_replace ( $ this -> replacementsOld , $ this -> replacementsNew , $ sql ) ; } return $ sql ; } | Generate the SQL statement for this query . |
4,247 | protected function copyTo ( SQLExpression $ object ) { $ target = array_keys ( get_object_vars ( $ object ) ) ; foreach ( get_object_vars ( $ this ) as $ variable => $ value ) { if ( in_array ( $ variable , $ target ) ) { $ object -> $ variable = $ value ; } } } | Copies the query parameters contained in this object to another SQLExpression |
4,248 | public function getTargetMember ( ) { $ tempid = $ this -> getRequest ( ) -> requestVar ( 'tempid' ) ; if ( $ tempid ) { return Member :: member_from_tempid ( $ tempid ) ; } return null ; } | Get known logged out member |
4,249 | protected function redirectToExternalLogin ( ) { $ loginURL = Security :: create ( ) -> Link ( 'login' ) ; $ loginURLATT = Convert :: raw2att ( $ loginURL ) ; $ loginURLJS = Convert :: raw2js ( $ loginURL ) ; $ message = _t ( __CLASS__ . '.INVALIDUSER' , '<p>Invalid user. <a target="_top" href="{link}">Please re-authen... | Redirects the user to the external login page |
4,250 | public function success ( ) { if ( ! Security :: getCurrentUser ( ) || ! class_exists ( AdminRootController :: class ) ) { return $ this -> redirectToExternalLogin ( ) ; } $ controller = $ this -> getResponseController ( _t ( __CLASS__ . '.SUCCESS' , 'Success' ) ) ; $ backURLs = array ( $ this -> getRequest ( ) -> requ... | Given a successful login tell the parent frame to close the dialog |
4,251 | protected function sendNotModified ( HTTPRequest $ request , HTTPResponse $ response ) { if ( in_array ( $ request -> httpMethod ( ) , [ 'POST' , 'DELETE' , 'PUT' ] ) ) { $ response -> setStatusCode ( 412 ) ; } else { $ response -> setStatusCode ( 304 ) ; } $ response -> setBody ( '' ) ; return $ response ; } | Sent not - modified response |
4,252 | protected function buildCurrencyField ( ) { $ name = $ this -> getName ( ) ; $ currencyValue = $ this -> fieldCurrency ? $ this -> fieldCurrency -> dataValue ( ) : null ; $ allowedCurrencies = $ this -> getAllowedCurrencies ( ) ; if ( count ( $ allowedCurrencies ) === 1 ) { $ field = HiddenField :: create ( "{$name}[Cu... | Builds a new currency field based on the allowed currencies configured |
4,253 | protected function getDBMoney ( ) { return DBMoney :: create_field ( 'Money' , [ 'Currency' => $ this -> fieldCurrency -> dataValue ( ) , 'Amount' => $ this -> fieldAmount -> dataValue ( ) ] ) -> setLocale ( $ this -> getLocale ( ) ) ; } | Get value as DBMoney object useful for formatting the number |
4,254 | public function setAllowedCurrencies ( $ currencies ) { if ( empty ( $ currencies ) ) { $ currencies = [ ] ; } elseif ( is_string ( $ currencies ) ) { $ currencies = [ $ currencies => $ currencies ] ; } elseif ( ! is_array ( $ currencies ) ) { throw new InvalidArgumentException ( "Invalid currency list" ) ; } elseif ( ... | Set list of currencies . Currencies should be in the 3 - letter ISO 4217 currency code . |
4,255 | public function Breadcrumbs ( ) { $ basePath = str_replace ( Director :: protocolAndHost ( ) , '' , Director :: absoluteBaseURL ( ) ) ; $ relPath = parse_url ( substr ( $ _SERVER [ 'REQUEST_URI' ] , strlen ( $ basePath ) , strlen ( $ _SERVER [ 'REQUEST_URI' ] ) ) , PHP_URL_PATH ) ; $ parts = explode ( '/' , $ relPath )... | Generate breadcrumb links to the URL path being displayed |
4,256 | public function renderHeader ( $ httpRequest = null ) { $ url = htmlentities ( $ _SERVER [ 'REQUEST_METHOD' ] . ' ' . $ _SERVER [ 'REQUEST_URI' ] , ENT_COMPAT , 'UTF-8' ) ; $ debugCSS = ModuleResourceLoader :: singleton ( ) -> resolveURL ( 'silverstripe/framework:client/styles/debug.css' ) ; $ output = '<!DOCTYPE html>... | Render HTML header for development views |
4,257 | public function renderError ( $ httpRequest , $ errno , $ errstr , $ errfile , $ errline ) { $ errorType = isset ( self :: $ error_types [ $ errno ] ) ? self :: $ error_types [ $ errno ] : self :: $ unknown_error ; $ httpRequestEnt = htmlentities ( $ httpRequest , ENT_COMPAT , 'UTF-8' ) ; if ( ini_get ( 'html_errors' )... | Render an error . |
4,258 | public function renderSourceFragment ( $ lines , $ errline ) { $ output = '<div class="info"><h3>Source</h3>' ; $ output .= '<pre>' ; foreach ( $ lines as $ offset => $ line ) { $ line = htmlentities ( $ line , ENT_COMPAT , 'UTF-8' ) ; if ( $ offset == $ errline ) { $ output .= "<span>$offset</span> <span class=\"error... | Render a fragment of the a source file |
4,259 | public function renderTrace ( $ trace ) { $ output = '<div class="info">' ; $ output .= '<h3>Trace</h3>' ; $ output .= Backtrace :: get_rendered_backtrace ( $ trace ) ; $ output .= '</div>' ; return $ output ; } | Render a call track |
4,260 | public function renderVariable ( $ val , $ caller ) { $ output = '<pre style="background-color:#ccc;padding:5px;font-size:14px;line-height:18px;">' ; $ output .= "<span style=\"font-size: 12px;color:#666;\">" . $ this -> formatCaller ( $ caller ) . " - </span>\n" ; if ( is_string ( $ val ) ) { $ output .= wordwrap ( $ ... | Outputs a variable in a user presentable way |
4,261 | public function addFrom ( $ from ) { if ( is_array ( $ from ) ) { $ this -> from = array_merge ( $ this -> from , $ from ) ; } elseif ( ! empty ( $ from ) ) { $ this -> from [ str_replace ( array ( '"' , '`' ) , '' , $ from ) ] = $ from ; } return $ this ; } | Add a table to include in the query or update |
4,262 | public function addLeftJoin ( $ table , $ onPredicate , $ tableAlias = '' , $ order = 20 , $ parameters = array ( ) ) { if ( ! $ tableAlias ) { $ tableAlias = $ table ; } $ this -> from [ $ tableAlias ] = array ( 'type' => 'LEFT' , 'table' => $ table , 'filter' => array ( $ onPredicate ) , 'order' => $ order , 'paramet... | Add a LEFT JOIN criteria to the tables list . |
4,263 | public function addInnerJoin ( $ table , $ onPredicate , $ tableAlias = null , $ order = 20 , $ parameters = array ( ) ) { if ( ! $ tableAlias ) { $ tableAlias = $ table ; } $ this -> from [ $ tableAlias ] = array ( 'type' => 'INNER' , 'table' => $ table , 'filter' => array ( $ onPredicate ) , 'order' => $ order , 'par... | Add an INNER JOIN criteria |
4,264 | public function queriedTables ( ) { $ tables = array ( ) ; foreach ( $ this -> from as $ key => $ tableClause ) { if ( is_array ( $ tableClause ) ) { $ table = '"' . $ tableClause [ 'table' ] . '"' ; } elseif ( is_string ( $ tableClause ) && preg_match ( '/JOIN +("[^"]+") +(AS|ON) +/i' , $ tableClause , $ matches ) ) {... | Return a list of tables that this query is selecting from . |
4,265 | public function getJoins ( & $ parameters = array ( ) ) { if ( func_num_args ( ) == 0 ) { Deprecation :: notice ( '4.0' , 'SQLConditionalExpression::getJoins() now may produce parameters which are necessary to execute this query' ) ; } $ parameters = array ( ) ; $ joins = $ this -> getOrderedJoins ( $ this -> from )... | Retrieves the finalised list of joins |
4,266 | public function setWhere ( $ where ) { $ where = func_num_args ( ) > 1 ? func_get_args ( ) : $ where ; $ this -> where = array ( ) ; return $ this -> addWhere ( $ where ) ; } | Set a WHERE clause . |
4,267 | public function filtersOnID ( ) { $ regexp = '/^(.*\.)?("|`)?ID("|`)?\s?(=|IN)/' ; foreach ( $ this -> getWhereParameterised ( $ parameters ) as $ predicate ) { if ( preg_match ( $ regexp , $ predicate ) ) { return true ; } } return false ; } | Checks whether this query is for a specific ID in a table |
4,268 | protected function isAPCUSupported ( ) { static $ apcuSupported = null ; if ( null === $ apcuSupported ) { $ apcuSupported = Director :: is_cli ( ) ? ini_get ( 'apc.enable_cli' ) && ApcuAdapter :: isSupported ( ) : ApcuAdapter :: isSupported ( ) ; } return $ apcuSupported ; } | Determine if apcu is supported |
4,269 | protected function getFormatter ( ) { if ( $ this -> getHTML5 ( ) ) { $ formatter = NumberFormatter :: create ( i18n :: config ( ) -> uninherited ( 'default_locale' ) , NumberFormatter :: DECIMAL ) ; $ formatter -> setAttribute ( NumberFormatter :: GROUPING_USED , false ) ; $ formatter -> setSymbol ( NumberFormatter ::... | Get number formatter for localising this field |
4,270 | public function Value ( ) { if ( $ this -> value === null || $ this -> value === false ) { return $ this -> originalValue ; } $ formatter = $ this -> getFormatter ( ) ; return $ formatter -> format ( $ this -> value , $ this -> getNumberType ( ) ) ; } | Format value for output |
4,271 | protected function cast ( $ value ) { if ( strlen ( $ value ) === 0 ) { return null ; } if ( $ this -> getScale ( ) === 0 ) { return ( int ) $ value ; } return ( float ) $ value ; } | Helper to cast non - localised strings to their native type |
4,272 | public function setMessage ( $ message , $ messageType = ValidationResult :: TYPE_ERROR , $ messageCast = ValidationResult :: CAST_TEXT ) { if ( ! in_array ( $ messageCast , [ ValidationResult :: CAST_TEXT , ValidationResult :: CAST_HTML ] ) ) { throw new InvalidArgumentException ( "Invalid message cast type" ) ; } $ t... | Sets the error message to be displayed on the form field . |
4,273 | public function getSchemaMessage ( ) { $ message = $ this -> getMessage ( ) ; if ( ! $ message ) { return null ; } if ( $ this -> getMessageCast ( ) === ValidationResult :: CAST_HTML ) { $ message = [ 'html' => $ message ] ; } return [ 'value' => $ message , 'type' => $ this -> getMessageType ( ) , ] ; } | Get form schema encoded message |
4,274 | protected function isTrustedProxy ( HTTPRequest $ request ) { $ trustedIPs = $ this -> getTrustedProxyIPs ( ) ; if ( empty ( $ trustedIPs ) || $ trustedIPs === 'none' ) { return false ; } if ( $ trustedIPs === '*' ) { return true ; } $ ip = $ request -> getIP ( ) ; if ( $ ip ) { return IPUtils :: checkIP ( $ ip , preg_... | Determine if the current request is coming from a trusted proxy |
4,275 | protected function getIPFromHeaderValue ( $ headerValue ) { $ ips = preg_split ( '/\s*,\s*/' , $ headerValue ) ; $ filters = [ FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE , FILTER_FLAG_NO_PRIV_RANGE , null ] ; foreach ( $ filters as $ filter ) { foreach ( $ ips as $ ip ) { if ( filter_var ( $ ip , FILTER_VALID... | Extract an IP address from a header value that has been obtained . Accepts single IP or comma separated string of IPs |
4,276 | protected function normaliseMessages ( $ messages , $ locale ) { foreach ( $ messages as $ key => $ value ) { $ messages [ $ key ] = $ this -> normaliseMessage ( $ key , $ value , $ locale ) ; } return $ messages ; } | Normalises plurals in messages from rails - yaml format to symfony . |
4,277 | protected function normaliseMessage ( $ key , $ value , $ locale ) { if ( ! is_array ( $ value ) ) { return $ value ; } if ( isset ( $ value [ 'default' ] ) ) { return $ value [ 'default' ] ; } $ pluralised = i18n :: encode_plurals ( $ value ) ; if ( $ pluralised ) { return $ pluralised ; } trigger_error ( "Localisatio... | Normalise rails - yaml plurals into pipe - separated rules |
4,278 | public function forForeignID ( $ id ) { if ( is_array ( $ id ) && sizeof ( $ id ) == 1 ) { $ id = reset ( $ id ) ; } $ filter = $ this -> foreignIDFilter ( $ id ) ; $ list = $ this -> alterDataQuery ( function ( DataQuery $ query ) use ( $ id , $ filter ) { $ currentFilter = $ query -> getQueryParam ( 'Foreign.Filter' ... | Returns a copy of this list with the ManyMany relationship linked to the given foreign ID . |
4,279 | protected function checkMatchingURL ( HTTPRequest $ request ) { $ patterns = $ this -> getURLPatterns ( ) ; if ( ! $ patterns ) { return null ; } $ relativeURL = $ request -> getURL ( true ) ; foreach ( $ patterns as $ pattern => $ result ) { if ( preg_match ( $ pattern , $ relativeURL ) ) { return $ result ; } } retur... | Check if global basic auth is enabled for the given request |
4,280 | protected function getListMap ( $ source ) { if ( $ source instanceof SS_List ) { $ source = $ source -> map ( ) ; } if ( $ source instanceof Map ) { $ source = $ source -> toArray ( ) ; } if ( ! is_array ( $ source ) && ! ( $ source instanceof ArrayAccess ) ) { user_error ( '$source passed in as invalid type' , E_USER... | Given a list of values extract the associative map of id = > title |
4,281 | public function isSelectedValue ( $ dataValue , $ userValue ) { if ( $ dataValue === $ userValue ) { return true ; } if ( $ dataValue === '' && $ userValue === null ) { return true ; } if ( is_array ( $ dataValue ) || is_array ( $ userValue ) ) { return false ; } if ( $ dataValue ) { return $ dataValue == $ userValue ;... | Determine if the current value of this field matches the given option value |
4,282 | public function castedCopy ( $ classOrCopy ) { $ field = parent :: castedCopy ( $ classOrCopy ) ; if ( $ field instanceof SelectField ) { $ field -> setSource ( $ this -> getSource ( ) ) ; } return $ field ; } | Returns another instance of this field but cast to a different class . |
4,283 | public function redirectBackToForm ( ) { $ url = $ this -> addBackURLParam ( Security :: singleton ( ) -> Link ( 'changepassword' ) ) ; return $ this -> redirect ( $ url ) ; } | Something went wrong go back to the changepassword |
4,284 | protected function checkPassword ( $ member , $ password ) { if ( empty ( $ password ) ) { return false ; } $ authenticators = Security :: singleton ( ) -> getApplicableAuthenticators ( Authenticator :: CHECK_PASSWORD ) ; foreach ( $ authenticators as $ authenticator ) { if ( ! $ authenticator -> checkPassword ( $ memb... | Check if password is ok |
4,285 | public function addAssignments ( array $ assignments ) { $ assignments = $ this -> normaliseAssignments ( $ assignments ) ; $ this -> assignments = array_merge ( $ this -> assignments , $ assignments ) ; return $ this ; } | Adds assignments for a list of several fields |
4,286 | public function handleRequest ( HTTPRequest $ request ) { Injector :: inst ( ) -> registerService ( $ request , HTTPRequest :: class ) ; $ rules = Director :: config ( ) -> uninherited ( 'rules' ) ; $ this -> extend ( 'updateRules' , $ rules ) ; $ handler = function ( ) { return new HTTPResponse ( 'No URL rule was matc... | Process the given URL creating the appropriate controller and executing it . |
4,287 | public static function absoluteURL ( $ url , $ relativeParent = self :: BASE ) { if ( is_bool ( $ relativeParent ) ) { Deprecation :: notice ( '5.0' , 'Director::absoluteURL takes an explicit parent for relative url' ) ; $ relativeParent = $ relativeParent ? self :: BASE : self :: REQUEST ; } if ( preg_match ( '/^http(... | Turns the given URL into an absolute URL . By default non - site root relative urls will be evaluated relative to the current base_url . |
4,288 | protected static function validateUserAndPass ( $ url ) { $ parsedURL = parse_url ( $ url ) ; if ( ! empty ( $ parsedURL [ 'user' ] ) && strstr ( $ parsedURL [ 'user' ] , '\\' ) ) { return false ; } if ( ! empty ( $ parsedURL [ 'pass' ] ) && strstr ( $ parsedURL [ 'pass' ] , '\\' ) ) { return false ; } return true ; } | Validate user and password in URL disallowing slashes |
4,289 | public static function port ( HTTPRequest $ request = null ) { $ host = static :: host ( $ request ) ; return ( int ) parse_url ( $ host , PHP_URL_PORT ) ? : null ; } | Return port used for the base URL . Note this will be null if not specified in which case you should assume the default port for the current protocol . |
4,290 | public static function hostName ( HTTPRequest $ request = null ) { $ host = static :: host ( $ request ) ; return parse_url ( $ host , PHP_URL_HOST ) ? : null ; } | Return host name without port |
4,291 | public static function is_https ( HTTPRequest $ request = null ) { if ( $ baseURL = self :: config ( ) -> uninherited ( 'alternate_base_url' ) ) { $ baseURL = Injector :: inst ( ) -> convertServiceProperty ( $ baseURL ) ; $ protocol = parse_url ( $ baseURL , PHP_URL_SCHEME ) ; if ( $ protocol ) { return $ protocol === ... | Return whether the site is running as under HTTPS . |
4,292 | public static function baseURL ( ) { $ alternate = self :: config ( ) -> get ( 'alternate_base_url' ) ; if ( $ alternate ) { $ alternate = Injector :: inst ( ) -> convertServiceProperty ( $ alternate ) ; return rtrim ( parse_url ( $ alternate , PHP_URL_PATH ) , '/' ) . '/' ; } $ baseURL = rtrim ( BASE_URL , '/' ) . '/'... | Return the root - relative url for the baseurl |
4,293 | public static function makeRelative ( $ url ) { $ url = preg_replace ( '#([^:])//#' , '\\1/' , trim ( $ url ) ) ; if ( preg_match ( '#^(?<protocol>https?:)?//(?<hostpart>[^/]*)(?<url>(/.*)?)$#i' , $ url , $ matches ) ) { $ url = $ matches [ 'url' ] ; } if ( trim ( $ url , '\\/' ) === '' ) { return '' ; } foreach ( [ se... | Turns an absolute URL or folder into one that s relative to the root of the site . This is useful when turning a URL into a filesystem reference or vice versa . |
4,294 | public static function getAbsFile ( $ file ) { if ( self :: is_absolute ( $ file ) ) { return $ file ; } if ( self :: publicDir ( ) ) { $ path = Path :: join ( self :: publicFolder ( ) , $ file ) ; if ( file_exists ( $ path ) ) { return $ path ; } } return Path :: join ( self :: baseFolder ( ) , $ file ) ; } | Given a filesystem reference relative to the site root return the full file - system path . |
4,295 | public static function absoluteBaseURLWithAuth ( HTTPRequest $ request = null ) { $ user = $ request -> getHeader ( 'PHP_AUTH_USER' ) ; if ( $ user ) { $ password = $ request -> getHeader ( 'PHP_AUTH_PW' ) ; $ login = sprintf ( "%s:%s@" , $ user , $ password ) ; } else { $ login = '' ; } return Director :: protocol ( $... | Returns the Absolute URL of the site root embedding the current basic - auth credentials into the URL . |
4,296 | public static function forceSSL ( $ patterns = null , $ secureDomain = null , HTTPRequest $ request = null ) { $ handler = CanonicalURLMiddleware :: singleton ( ) -> setForceSSL ( true ) ; if ( $ patterns ) { $ handler -> setForceSSLPatterns ( $ patterns ) ; } if ( $ secureDomain ) { $ handler -> setForceSSLDomain ( $ ... | Force the site to run on SSL . |
4,297 | public static function forceWWW ( HTTPRequest $ request = null ) { $ handler = CanonicalURLMiddleware :: singleton ( ) -> setForceWWW ( true ) ; $ handler -> throwRedirectIfNeeded ( $ request ) ; } | Force a redirect to a domain starting with www . |
4,298 | public static function is_ajax ( HTTPRequest $ request = null ) { $ request = self :: currentRequest ( $ request ) ; if ( $ request ) { return $ request -> isAjax ( ) ; } return ( isset ( $ _REQUEST [ 'ajax' ] ) || ( isset ( $ _SERVER [ 'HTTP_X_REQUESTED_WITH' ] ) && $ _SERVER [ 'HTTP_X_REQUESTED_WITH' ] == "XMLHttpReq... | Checks if the current HTTP - Request is an Ajax - Request by checking for a custom header set by jQuery or whether a manually set request - parameter ajax is present . |
4,299 | protected static function currentRequest ( HTTPRequest $ request = null ) { if ( ! $ request && Injector :: inst ( ) -> has ( HTTPRequest :: class ) ) { $ request = Injector :: inst ( ) -> get ( HTTPRequest :: class ) ; } return $ request ; } | Helper to validate or check the current request object |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.