idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
55,700
public function addTab ( $ key , $ label , $ icon , $ priority = 0 , $ messageCount = 0 ) { $ this -> tabs [ $ key ] = [ 'priority' => $ priority , 'key' => $ key , 'label' => $ label , 'icon' => $ icon , 'count' => $ messageCount , ] ; $ this -> items [ $ key ] = [ ] ; return $ this ; }
Add an tab to the contextual pane
55,701
public function add ( $ value , $ tab , $ priority = 0 ) { if ( ! empty ( $ value ) ) { if ( is_string ( $ value ) ) { $ this -> items [ $ tab ] [ $ priority ] [ ] = [ '#markup' => $ value ] ; } else { $ this -> items [ $ tab ] [ $ priority ] [ ] = $ value ; } } return $ this ; }
Add an item to the contextual pane
55,702
public function getAll ( ) { foreach ( $ this -> getTabs ( ) as $ key => $ label ) { ksort ( $ this -> items [ $ key ] ) ; } return $ this -> items ; }
Get all ordered pane items indexed by tab key .
55,703
public function getTabs ( ) { uasort ( $ this -> tabs , function ( $ a , $ b ) { return $ a [ 'priority' ] - $ b [ 'priority' ] ; } ) ; return $ this -> tabs ; }
Get all ordered tabs indexed by tab key .
55,704
public function addActions ( $ actions , $ title = null , $ icon = null , $ showTitle = false ) { if ( $ actions ) { $ this -> actions [ ] = [ 'title' => $ title , 'icon' => $ icon , 'showTitle' => empty ( $ icon ) ? true : $ showTitle , 'actions' => $ actions , 'raw' => ( ! is_array ( $ actions ) || ! reset ( $ actions ) instanceof Action ) ] ; } return $ this ; }
Add a group of actions for this context .
55,705
public function getDefaultViewParam ( $ name , $ default = null ) { return isset ( $ this -> default_view_params [ $ name ] ) ? $ this -> default_view_params [ $ name ] : $ default ; }
Get a value of the default parameters for all views
55,706
public function setIncludePath ( $ path ) { if ( file_exists ( $ path ) ) { array_push ( $ this -> include_paths , $ path ) ; return $ this ; } else { throw new TemplateEngineException ( sprintf ( 'Directory "%s" defined as views path can\'t be found!' , $ path ) ) ; } }
Define a new include path for view files
55,707
public function getTemplate ( $ path ) { if ( file_exists ( $ path ) ) { return $ path ; } elseif ( false !== $ path_rp = realpath ( $ path ) ) { return $ path_rp ; } else { foreach ( $ this -> getIncludePath ( ) as $ _path ) { $ _f = DirectoryHelper :: slashDirname ( $ _path ) . $ path ; if ( file_exists ( $ _f ) ) { return $ _f ; } } } return null ; }
Search a view file in the current file system
55,708
protected function _extractSequence ( $ file ) { $ sequence = '' ; $ hlpr = Mage :: helper ( 'radial_core' ) ; $ domDocument = $ hlpr -> getNewDomDocument ( ) ; $ domDocument -> load ( $ file ) ; $ feedXpath = $ hlpr -> getNewDomXPath ( $ domDocument ) ; $ correlationId = $ feedXpath -> query ( '//MessageHeader/MessageData/CorrelationId' ) ; if ( $ correlationId -> length ) { $ sequence = ( string ) $ correlationId -> item ( 0 ) -> nodeValue ; } return $ sequence ; }
Extract the sequence number from xml feed file .
55,709
public function buildSequence ( $ feeds ) { $ results = array ( ) ; if ( ! empty ( $ feeds ) ) { foreach ( $ feeds as $ feed ) { $ results [ ] = array ( 'sequence' => $ this -> _extractSequence ( $ feed ) , 'feed' => $ feed ) ; } } return $ results ; }
get feeds sequence .
55,710
public function message ( $ force_full_length = false ) { if ( is_null ( $ this -> is_trimmed ) && ! $ force_full_length ) { $ this -> is_trimmed = $ this -> trim ( ) ; } return ( $ this -> is_trimmed && ! $ force_full_length ) ? $ this -> trimmed_message : $ this -> message ; }
Returns the message trimmed or in full length
55,711
private function trim ( ) { if ( utf8_strlen ( $ this -> message ) <= ( $ this -> length + $ this -> length_tolerance ) ) { return false ; } if ( ! $ this -> bbcode_uid ) { $ this -> trimmed_message = utf8_substr ( $ this -> message , 0 , $ this -> length ) . $ this -> append_str ; return true ; } $ this -> trim_action ( ) ; return $ this -> bbcodes -> is_trimmed ( ) ; }
Filter some easy cases where we can return the result easily
55,712
private function trim_action ( ) { $ this -> trimmed_message = $ this -> message ; $ this -> bbcodes = new PhpbbBbcodes ( $ this -> trimmed_message , $ this -> bbcode_uid , $ this -> length ) ; $ this -> bbcodes -> get_bbcodes ( ) ; $ this -> bbcodes -> remove_bbcodes_after ( ) ; $ this -> trimmed_message = utf8_substr ( $ this -> message , 0 , $ this -> bbcodes -> get_trim_position ( ) ) ; $ this -> remove_broken_links ( ) ; $ text_length = utf8_strlen ( $ this -> trimmed_message ) ; if ( $ this -> bbcodes -> is_trimmed ( ) ) { $ this -> trimmed_message .= $ this -> append_str ; } $ open_bbcodes = $ this -> bbcodes -> get_open_bbcodes_after ( $ text_length ) ; $ this -> close_bbcodes ( $ open_bbcodes ) ; }
Do some magic ... uhhh
55,713
private function remove_broken_links ( ) { $ open_brakets = substr_count ( $ this -> trimmed_message , '<' ) ; $ closing_brakets = substr_count ( $ this -> trimmed_message , '>' ) ; if ( $ open_brakets != $ closing_brakets ) { $ this -> trimmed_message = utf8_substr ( $ this -> trimmed_message , 0 , utf8_strrpos ( $ this -> trimmed_message , '<' ) ) ; } $ open_link = substr_count ( $ this -> trimmed_message , '<!-- ' ) ; if ( ( $ open_link % 2 ) == 1 ) { $ this -> trimmed_message = utf8_substr ( $ this -> trimmed_message , 0 , utf8_strrpos ( $ this -> trimmed_message , '<!-- ' ) ) ; return ; } }
Removes broken smilies emails and links without the URL - tag .
55,714
private function close_bbcodes ( $ open_bbcodes ) { foreach ( $ open_bbcodes as $ bbcode_tag ) { $ this -> trimmed_message .= '[/' . $ bbcode_tag . ':' . $ this -> bbcode_uid . ']' ; } }
Close all open bbcodes
55,715
public function offsetSet ( $ object , $ data = null ) { if ( ! parent :: contains ( $ object ) ) { parent :: attach ( $ object , $ data ) ; $ this -> map [ $ this -> index ++ ] = spl_object_hash ( $ object ) ; while ( parent :: valid ( ) ) { parent :: next ( ) ; } } }
Add an object to the storage and set the internal pointer on it
55,716
public function offsetUnset ( $ object ) { if ( parent :: contains ( $ object ) ) { parent :: offsetUnset ( $ object ) ; $ index = array_search ( spl_object_hash ( $ object ) , $ this -> map , true ) ; unset ( $ this -> map [ $ index ] ) ; } }
Remove an object from the storage
55,717
public function getObjectByHash ( $ hash ) { $ index = array_search ( $ hash , $ this -> map , true ) ; if ( false !== $ index ) { parent :: rewind ( ) ; while ( parent :: valid ( ) ) { if ( parent :: key ( ) === $ index ) { return parent :: current ( ) ; } parent :: next ( ) ; } } }
Returns the object identified by its hashcode
55,718
public function getObjectByKey ( $ key ) { if ( isset ( $ this -> map [ $ key ] ) ) { parent :: rewind ( ) ; while ( parent :: valid ( ) ) { if ( parent :: key ( ) === $ key ) { return parent :: current ( ) ; } parent :: next ( ) ; } } }
Returns the object identified by its position in the storage
55,719
public function getObjectByInfo ( $ info ) { parent :: rewind ( ) ; while ( parent :: valid ( ) ) { if ( parent :: getInfo ( ) === $ info ) { return parent :: current ( ) ; } parent :: next ( ) ; } }
Returns the object identified by its attached info In case of many identical infos the first attached object is returned
55,720
public function getKeyByHash ( $ hash ) { $ index = array_search ( $ hash , $ this -> map , true ) ; return ( false === $ index ) ? null : $ index ; }
Returns the position of an object in the storage Object identified by its hashcode
55,721
public function getInfoByHash ( $ hash ) { $ index = array_search ( $ hash , $ this -> map , true ) ; if ( false !== $ index ) { return $ this -> getInfoByKey ( $ index ) ; } }
Returns the data associated with an object identified by its hashcode
55,722
public function getInfoByKey ( $ key ) { if ( isset ( $ this -> map [ $ key ] ) ) { parent :: rewind ( ) ; while ( parent :: valid ( ) ) { if ( parent :: key ( ) === $ key ) { return parent :: getInfo ( ) ; } parent :: next ( ) ; } } }
Returns the data associated with an object identified by its position
55,723
public function selectObjectByHash ( $ hash ) { $ index = array_search ( $ hash , $ this -> map , true ) ; return ( false !== $ index ) ? $ this -> selectObjectByKey ( $ index ) : false ; }
Move the internal pointer to an object identified by its hashcode
55,724
public function selectObjectByKey ( $ key ) { if ( isset ( $ this -> map [ $ key ] ) ) { parent :: rewind ( ) ; while ( parent :: valid ( ) ) { if ( parent :: key ( ) === $ key ) { return true ; } parent :: next ( ) ; } } return false ; }
Move the internal pointer to an object identified by its position in the storage
55,725
public function selectObjectByInfo ( $ info ) { parent :: rewind ( ) ; while ( parent :: valid ( ) ) { if ( parent :: getInfo ( ) === $ info ) { return true ; } parent :: next ( ) ; } return false ; }
Select the object identified by its attached info In case of many identical infos the first attached object is selected
55,726
public function getPixel ( $ image , $ x , $ y ) { return imagecolorsforindex ( $ image , imagecolorat ( $ image , $ x , $ y ) ) ; }
Get pixel value from image resource
55,727
public function loadFromString ( $ image ) { $ resource = @ imagecreatefromstring ( $ image ) ; if ( ! is_resource ( $ resource ) ) { throw new Exception \ RuntimeException ( 'image could not be loaded' ) ; } return $ resource ; }
Load image from string
55,728
public function saveToString ( $ image , $ options ) { $ outputMethod = $ this -> getOutputMethod ( $ options ) ; ob_start ( ) ; $ outputMethod ( $ image ) ; $ string = ob_get_contents ( ) ; ob_end_clean ( ) ; return $ string ; }
Save image to string
55,729
protected function getOutputMethod ( $ options ) { $ outputMethod = 'imagegd' ; if ( isset ( $ options [ 'format' ] ) ) { $ outputMethod = 'image' . image_type_to_extension ( $ options [ 'format' ] , false ) ; } return $ outputMethod ; }
Get output method for given format
55,730
function getMetaData ( $ key = null ) { $ data = $ this -> data ; if ( $ key !== null ) $ data = ( isset ( $ data [ $ key ] ) ) ? $ data [ $ key ] : null ; return $ data ; }
Data Embed With User Identity
55,731
private static function validateDateTime ( $ datetime ) { if ( $ datetime instanceof DateTimeInterface || $ datetime instanceof DateTime ) { return $ datetime ; } return new DateTime ( ( string ) $ datetime ) ; }
Validate a DateTime .
55,732
public function getDuration ( $ getAsSeconds = false ) { if ( true === $ getAsSeconds ) { return $ this -> end -> getTimestamp ( ) - $ this -> start -> getTimestamp ( ) ; } return $ this -> start -> diff ( $ this -> end ) ; }
Return the Period duration as a DateInterval object .
55,733
public function getRange ( $ interval ) { return new DatePeriod ( $ this -> start , self :: validateDateInterval ( $ interval ) , $ this -> end ) ; }
Return a list of Datetime objects included in the Period according to a given interval .
55,734
private static function validateDateInterval ( $ interval ) { if ( $ interval instanceof DateInterval ) { return $ interval ; } $ res = filter_var ( $ interval , FILTER_VALIDATE_INT , array ( 'options' => array ( 'min_range' => 0 ) ) ) ; if ( false !== $ res ) { return new DateInterval ( 'PT' . $ res . 'S' ) ; } return DateInterval :: createFromDateString ( ( string ) $ interval ) ; }
Validate a DateInterval .
55,735
public function sameValueAs ( Period $ period ) { return $ this -> start == $ period -> start && $ this -> end == $ period -> end ; }
Tell whether both Period objects share the same endpoints .
55,736
public function abuts ( Period $ period ) { return $ this -> start == $ period -> end || $ this -> end == $ period -> start ; }
Tell whether the current Period object abuts the specified Period
55,737
public function overlaps ( Period $ period ) { if ( $ this -> abuts ( $ period ) ) { return false ; } return $ this -> start < $ period -> end && $ this -> end > $ period -> start ; }
Tell whether two Period objects overlaps .
55,738
private static function createFromEndpoints ( $ endpoint1 , $ endpoint2 ) { $ start = self :: validateDateTime ( $ endpoint1 ) ; $ end = self :: validateDateTime ( $ endpoint2 ) ; if ( $ start > $ end ) { return new self ( $ end , $ start ) ; } return new self ( $ start , $ end ) ; }
Create a new Period instance given two endpoints The endpoints will be used as to allow the creation of a Period object
55,739
public function durationDiff ( Period $ period , $ get_as_seconds = false ) { $ diff = $ this -> end -> getTimestamp ( ) - $ this -> start -> getTimestamp ( ) - $ period -> end -> getTimestamp ( ) + $ period -> start -> getTimestamp ( ) ; if ( ! $ get_as_seconds ) { $ res = new DateInterval ( 'PT' . abs ( $ diff ) . 'S' ) ; if ( 0 > $ diff ) { $ res -> invert = 1 ; } return $ res ; } return $ diff ; }
Returns the difference between two Period objects .
55,740
public function compareDuration ( Period $ period ) { $ datetime = new DateTime ( ) ; $ alt = clone $ datetime ; $ datetime -> add ( $ this -> start -> diff ( $ this -> end ) ) ; $ alt -> add ( $ period -> start -> diff ( $ period -> end ) ) ; if ( $ datetime > $ alt ) { return 1 ; } elseif ( $ datetime < $ alt ) { return - 1 ; } return 0 ; }
Compare two Period objects according to their duration .
55,741
public static function createFromDuration ( $ start , $ duration ) { $ start = self :: validateDateTime ( $ start ) ; $ end = clone $ start ; return new self ( $ start , $ end -> add ( self :: validateDateInterval ( $ duration ) ) ) ; }
Create a Period object from a starting point and an interval .
55,742
public static function createFromDurationBeforeEnd ( $ end , $ duration ) { $ end = self :: validateDateTime ( $ end ) ; $ start = clone $ end ; return new self ( $ start -> sub ( self :: validateDateInterval ( $ duration ) ) , $ end ) ; }
Create a Period object from a ending endpoint and an interval .
55,743
public static function createFromWeek ( $ year , $ week ) { $ start = new DateTime ( ) ; $ start -> setISODate ( self :: validateYear ( $ year ) , self :: validateRange ( $ week , 1 , 53 ) ) ; $ start -> setTime ( 0 , 0 , 0 ) ; return self :: createFromDuration ( $ start , '1 WEEK' ) ; }
Create a Period object from a Year and a Week .
55,744
private static function validateYear ( $ year ) { $ year = filter_var ( $ year , FILTER_VALIDATE_INT ) ; if ( false === $ year ) { throw new InvalidArgumentException ( "A Year must be a valid int" ) ; } return $ year ; }
Validate a year .
55,745
private static function validateRange ( $ value , $ min , $ max ) { $ res = filter_var ( $ value , FILTER_VALIDATE_INT , array ( 'options' => array ( 'min_range' => $ min , 'max_range' => $ max ) ) ) ; if ( false === $ res ) { throw new OutOfRangeException ( "the submitted value is not contained within the valid range" ) ; } return $ res ; }
Validate a int according to a range .
55,746
public static function createFromMonth ( $ year , $ month ) { $ year = self :: validateYear ( $ year ) ; $ month = self :: validateRange ( $ month , 1 , 12 ) ; return self :: createFromDuration ( $ year . '-' . sprintf ( '%02s' , $ month ) . '-01' , '1 MONTH' ) ; }
Create a Period object from a Year and a Month .
55,747
public function add ( $ duration ) { $ end = clone $ this -> end ; return new self ( $ this -> start , $ end -> add ( self :: validateDateInterval ( $ duration ) ) ) ; }
Add an interval to the current Period object
55,748
public function sub ( $ duration ) { $ end = clone $ this -> end ; return new self ( $ this -> start , $ end -> sub ( self :: validateDateInterval ( $ duration ) ) ) ; }
Remove an interval to the current Period object .
55,749
public function next ( $ duration = null ) { if ( is_null ( $ duration ) ) { $ duration = $ this -> getDuration ( ) ; } return self :: createFromDuration ( $ this -> end , $ duration ) ; }
return a new Period object adjacent to the current Period and starting with its ending endpoint . If no duration is provided the new Period will be created using the current object duration
55,750
public function previous ( $ duration = null ) { if ( is_null ( $ duration ) ) { $ duration = $ this -> getDuration ( ) ; } return self :: createFromDurationBeforeEnd ( $ this -> start , $ duration ) ; }
return a new Period object adjacent to the current Period and ending with its starting endpoint . If no duration is provided the new Period will have the same duration as the current one
55,751
public function merge ( ) { $ args = func_get_args ( ) ; if ( ! $ args ) { throw new InvalidArgumentException ( 'A Period object is missing' ) ; } $ res = clone $ this ; array_walk ( $ args , function ( Period $ period ) use ( & $ res ) { $ start = $ period -> getStart ( ) ; if ( $ res -> getStart ( ) > $ start ) { $ res = $ res -> startingOn ( $ start ) ; } $ end = $ period -> getEnd ( ) ; if ( $ res -> getEnd ( ) < $ end ) { $ res = $ res -> endingOn ( $ end ) ; } } ) ; return $ res ; }
Merge one or more Period objects to return a new Period object .
55,752
public function intersect ( Period $ period ) { if ( ! $ this -> overlaps ( $ period ) ) { throw new LogicException ( 'Both Period objects should overlaps' ) ; } $ start = $ this -> start ; if ( $ period -> start > $ start ) { $ start = $ period -> start ; } $ end = $ this -> end ; if ( $ period -> end < $ end ) { $ end = $ period -> end ; } return new self ( $ start , $ end ) ; }
Compute the intersection between two Period objects .
55,753
public function gap ( Period $ period ) { if ( $ this -> overlaps ( $ period ) ) { throw new LogicException ( 'Both Period objects should not overlaps' ) ; } if ( $ period -> start > $ this -> start ) { return new self ( $ this -> end , $ period -> start ) ; } return new self ( $ period -> end , $ this -> start ) ; }
Compute the gap between two Period objects .
55,754
public function normalize ( Content $ content , ThemeInterface $ theme , TemplateInterface $ template , ZoneInterface $ zone , ComponentInterface $ component ) { return array ( '_s_context' => array ( 'content' => array ( $ content -> getType ( ) -> getName ( ) , $ content -> getContentId ( ) ) , 'theme' => $ theme -> getName ( ) , 'template' => $ template -> getId ( ) , 'zone' => $ zone -> getId ( ) , 'component' => $ component -> getId ( ) , ) ) ; }
Normalize given context data into an array .
55,755
public function error ( $ errors = false ) { if ( $ errors === false ) { return $ this -> error ; } else { if ( is_array ( $ errors ) === true ) { foreach ( $ erros as $ error ) { $ this -> error ( $ error ) ; } } } $ this -> error [ ] = ( string ) $ errors ; }
- > debug errors?
55,756
public function validateCreate ( & $ submitted , $ options = array ( ) ) { $ this -> options = $ options ; $ this -> submitted = & $ submitted ; $ this -> validateNameCreate ( ) ; $ this -> validateDestinationCreate ( ) ; return $ this -> getResult ( ) ; }
Validates an array of submitted data while creating a new file
55,757
public function getPerimeter ( bool $ _3D = false ) : float { $ event = new MeasurementOpEvent ( $ this , [ '3D' => $ _3D ] ) ; $ this -> fireOperationEvent ( MeasurementOpEvent :: PERIMETER_EVENT , $ event ) ; return $ event -> getResults ( ) ; }
Get the perimeter of the Surface as measured in the spatial reference system of this Surface .
55,758
public function getPointOnSurface ( ) : Point { $ event = new SpatialRelationshipOpEvent ( $ this ) ; $ this -> fireOperationEvent ( SpatialRelationshipOpEvent :: POINT_ON_SURFACE_EVENT , $ event ) ; return $ event -> getResults ( ) ; }
A Point guaranteed to be on this Surface .
55,759
public function where ( $ condition , $ parameters = [ ] ) { $ this -> emptyResult ( ) ; $ this -> queryBuilder -> addWhere ( $ condition , $ parameters ) ; return $ this ; }
Adds where condition more calls appends with AND .
55,760
public function wherePrimary ( $ key ) { $ this -> where ( $ this -> primaryKey . ' = ' . $ this -> primaryModifier , $ key ) ; return $ this ; }
Condition for finding by primary key .
55,761
public function order ( $ items ) { $ this -> emptyResult ( ) ; empty ( $ items ) ? $ this -> queryBuilder -> order ( NULL ) : $ this -> queryBuilder -> addOrder ( func_get_args ( ) ) ; return $ this ; }
Adds order clause more calls appends to the end .
55,762
public function limit ( $ limit , $ offset = NULL ) { $ this -> emptyResult ( ) ; $ this -> queryBuilder -> limit ( $ limit , $ offset ) ; return $ this ; }
Sets limit more calls rewrite old values .
55,763
public function count ( $ column = NULL ) { if ( $ column ) { return $ this -> sum ( $ column ) ; } if ( $ this -> result ) { return count ( $ this -> result ) ; } list ( , $ criteria , $ options ) = $ this -> queryBuilder -> buildSelectQuery ( ) ; return $ this -> query -> count ( $ this -> name , $ criteria , $ options ) ; }
Counts number of documents .
55,764
public function having ( $ condition , $ parameter = [ ] ) { $ this -> emptyResult ( ) ; $ this -> queryBuilder -> addHaving ( $ condition , $ parameter ) ; return $ this ; }
Sets having clause more calls rewrite old value .
55,765
public function aggregate ( $ type , $ item ) { $ selection = $ this -> createSelectionInstance ( ) ; $ selection -> getQueryBuilder ( ) -> importConditions ( $ this -> queryBuilder ) ; $ selection -> select ( "$type($item) AS _gres" ) ; if ( ( $ result = $ selection -> fetch ( ) ) && isset ( $ result -> _gres ) ) { return $ result -> _gres ; } return NULL ; }
Executes aggregation function .
55,766
public static function isString ( $ item , $ o , $ m ) { if ( ! is_string ( $ item ) ) { throw new InvalidTypeException ( sprintf ( 'String parameter expected for %s in %s' , $ m , $ o ) ) ; } return true ; }
Tests to make sure the item being tested is actually a string .
55,767
public static function rangeCheck ( $ input , $ high , $ low , $ o , $ m ) { if ( is_integer ( $ high ) && is_integer ( $ low ) && is_integer ( $ input ) ) { $ filteredInput = filter_var ( $ input , FILTER_VALIDATE_INT , [ 'options' => [ 'min_range' => $ low , 'max_range' => $ high , ] , ] ) ; if ( ! $ filteredInput ) { throw new OutOfRangeException ( 'Integer range for ' . $ m . ' in ' . $ o . ' is ' . $ low . ' to ' . $ high ) ; } } else { throw new InvalidTypeException ( sprintf ( 'Integer parameter expected for %s in %s' , $ m , $ o ) ) ; } return true ; }
Tests to make sure that the integer is within a permissible range .
55,768
public function setHeaders ( array $ headers ) { foreach ( $ this -> headers as $ name => $ value ) { $ this -> addHeader ( $ name , $ value ) ; } return $ this ; }
Sets an array of response headers .
55,769
public static function _rollBack ( ) { if ( self :: $ _lastID ) { if ( ! static :: _delete ( self :: $ _lastID ) ) { return FALSE ; } self :: $ _lastID = FALSE ; } return TRUE ; }
Remove the last log entry
55,770
public function index ( ) { $ leftandmain = Injector :: inst ( ) -> create ( LeftAndMain :: class ) ; $ form = $ this -> Form ( ) ; $ form -> setTemplate ( $ leftandmain -> getTemplatesWithSuffix ( '_EditForm' ) ) ; $ form -> addExtraClass ( 'cms-edit-form center cms-content' ) ; $ form -> setAttribute ( 'data-pjax-fragment' , 'CurrentForm Content' ) ; if ( $ this -> request -> isAjax ( ) ) { $ response = new HTTPResponse ( Convert :: raw2json ( array ( 'Content' => $ form -> forAjaxTemplate ( ) -> getValue ( ) ) ) ) ; $ response -> addHeader ( 'X-Pjax' , 'Content' ) ; $ response -> addHeader ( 'Content-Type' , 'text/json' ) ; $ response -> addHeader ( 'X-Title' , 'SilverStripe - Bulk ' . $ this -> gridField -> list -> dataClass . ' Editing' ) ; return $ response ; } else { $ controller = $ this -> getToplevelController ( ) ; return $ controller -> customise ( array ( 'Content' => $ form ) ) ; } }
Creates and return the editing interface
55,771
private function getFilterParams ( $ path ) { if ( ! $ path ) { $ path = "" ; } $ parts = explode ( "/" , $ path ) ; if ( $ path == "" ) { } elseif ( count ( $ parts ) == 1 ) { $ this -> filterParameters [ 'id' ] = $ parts [ 0 ] ; } else { foreach ( $ parts as $ key => $ part ) { if ( ( $ key % 2 ) == 1 ) { $ this -> filterParameters [ $ parts [ $ key - 1 ] ] = urldecode ( $ part ) ; } else { $ this -> filterParameters [ $ part ] = "" ; } } } $ this -> filterParameters = array_merge ( $ _GET , $ this -> filterParameters ) ; }
Get all filter params from uri path
55,772
private function parseOperators ( $ params ) { foreach ( $ params as $ key => $ input ) { if ( is_array ( $ input ) ) { } elseif ( substr ( $ input , 0 , 1 ) == "!" ) { $ params [ $ key ] = array ( "NOT" => $ this -> parseValue ( substr ( $ input , 1 ) ) ) ; } elseif ( substr ( $ input , 0 , 2 ) == "><" ) { $ params [ $ key ] = array ( "BETWEEN" => $ this -> parseValue ( substr ( $ input , 2 ) ) ) ; } elseif ( substr ( $ input , 0 , 2 ) == ">=" ) { $ params [ $ key ] = array ( "GTE" => $ this -> parseValue ( substr ( $ input , 2 ) ) ) ; } elseif ( substr ( $ input , 0 , 2 ) == "<=" ) { $ params [ $ key ] = array ( "LTE" => $ this -> parseValue ( substr ( $ input , 2 ) ) ) ; } elseif ( substr ( $ input , 0 , 1 ) == "<" ) { $ params [ $ key ] = array ( "LT" => $ this -> parseValue ( substr ( $ input , 1 ) ) ) ; } elseif ( substr ( $ input , 0 , 1 ) == ">" ) { $ params [ $ key ] = array ( "GT" => $ this -> parseValue ( substr ( $ input , 1 ) ) ) ; } else { $ params [ $ key ] = $ this -> parseValue ( $ input ) ; } } return $ params ; }
Loop through parameters and parse operators
55,773
private function parseValue ( $ input ) { if ( is_array ( $ input ) ) { } elseif ( substr ( $ input , 0 , 1 ) === '"' && substr ( $ input , - 1 ) === '"' ) { $ input = substr ( $ input , 1 , - 1 ) ; } elseif ( strpos ( $ input , "|" ) !== false ) { $ input = explode ( "|" , $ input ) ; foreach ( $ input as $ key => $ value ) { $ input [ $ key ] = $ this -> parseValue ( $ value ) ; } } elseif ( $ input === "false" ) { $ input = false ; } elseif ( $ input === "true" ) { $ input = true ; } elseif ( is_numeric ( $ input ) ) { if ( strpos ( $ input , "." ) !== false ) { $ input = ( float ) $ input ; } else { $ input = ( int ) $ input ; } } elseif ( $ input === "on" ) { $ input = true ; } return $ input ; }
Formats the value for internals
55,774
private function parseParameterValues ( ) { $ this -> filterParameters = $ this -> parseOperators ( $ this -> filterParameters ) ; foreach ( $ this -> dataParameters as $ key => $ input ) { $ this -> dataParameters [ $ key ] = $ this -> parseValue ( $ input ) ; } }
Loop through filter parameters and formats the values for internals
55,775
public function getDataParams ( ) { $ method = $ _SERVER [ 'REQUEST_METHOD' ] ; switch ( $ method ) { case "POST" : $ this -> dataParameters = $ this -> getPostFromInput ( ) ; break ; case "PUT" : case "DELETE" : $ this -> dataParameters = $ this -> getPostFromInput ( ) ; break ; } }
Get data params based on request method
55,776
protected function grammar ( ) { if ( isset ( $ this -> grammar ) ) return $ this -> grammar ; switch ( isset ( $ this -> config [ 'grammar' ] ) ? $ this -> config [ 'grammar' ] : $ this -> driver ( ) ) { case 'mysql' : return $ this -> grammar = new Query \ Grammars \ MySQL ( $ this ) ; case 'sqlsrv' : return $ this -> grammar = new Query \ Grammars \ SQLServer ( $ this ) ; default : return $ this -> grammar = new Query \ Grammars \ Grammar ( $ this ) ; } }
Create a new query grammar for the connection .
55,777
public function only ( $ sql , $ bindings = array ( ) ) { $ results = ( array ) $ this -> first ( $ sql , $ bindings ) ; return reset ( $ results ) ; }
Execute a SQL query against the connection and return a single column result .
55,778
public function first ( $ sql , $ bindings = array ( ) ) { if ( count ( $ results = $ this -> query ( $ sql , $ bindings ) ) > 0 ) { return $ results [ 0 ] ; } }
Execute a SQL query against the connection and return the first result .
55,779
public function query ( $ sql , $ bindings = array ( ) ) { list ( $ statement , $ result ) = $ this -> execute ( $ sql , $ bindings ) ; return $ statement -> fetchAll ( PDO :: FETCH_CLASS , 'stdClass' ) ; }
Execute a SQL query and return an array of StdClass objects .
55,780
public function update ( $ sql , $ bindings = array ( ) ) { list ( $ statement , $ result ) = $ this -> execute ( $ sql , $ bindings ) ; return $ statement -> rowCount ( ) ; }
Execute a SQL UPDATE query and return the affected row count .
55,781
public function statement ( $ sql , $ bindings = array ( ) ) { list ( $ statement , $ result ) = $ this -> execute ( $ sql , $ bindings ) ; return $ result ; }
Execute an SQL query and return the boolean result of the PDO statement .
55,782
protected function execute ( $ sql , $ bindings = array ( ) ) { $ bindings = ( array ) $ bindings ; $ bindings = array_values ( array_filter ( $ bindings , function ( $ binding ) { return ! $ binding instanceof Expression ; } ) ) ; $ sql = $ this -> grammar ( ) -> shortcut ( $ sql , $ bindings ) ; $ statement = $ this -> pdo -> prepare ( $ sql ) ; $ time = microtime ( true ) ; $ result = $ statement -> execute ( $ bindings ) ; $ time = number_format ( ( microtime ( true ) - $ time ) * 1000 , 2 ) ; $ this -> log ( $ sql , $ bindings , $ time ) ; return array ( $ statement , $ result ) ; }
Execute a SQL query against the connection .
55,783
protected function log ( $ sql , $ bindings , $ time ) { Event :: fire ( 'Query' , array ( $ sql , $ bindings , $ time ) ) ; static :: $ queries = compact ( 'sql' , 'bindings' , 'time' ) ; }
Log the query and fire the core query event .
55,784
public function inEnum ( $ enum , $ strict = true ) { if ( ! $ this -> _isValid ) { return $ this ; } if ( ! in_array ( $ this -> _unsafeVar , $ enum , $ strict ) ) { $ this -> _isValid = false ; } return $ this ; }
The wrapped var MUST in the specified enum .
55,785
public function match ( $ pattern ) { if ( ! $ this -> _isValid ) { return $ this ; } if ( ! preg_match ( $ pattern , $ this -> _unsafeVar ) ) { $ this -> _isValid = false ; } return $ this ; }
The wrapped var MUST match the specified regular expression
55,786
public function notMatch ( $ pattern ) { if ( ! $ this -> _isValid ) { return $ this ; } if ( preg_match ( $ pattern , $ this -> _unsafeVar ) ) { $ this -> _isValid = false ; } return $ this ; }
The wrapped var MUST NOT match the specified regular expression
55,787
protected function beforeAction ( ) { if ( Lb :: app ( ) -> isRest ( ) ) { $ restConfig = Lb :: app ( ) -> getRest ( ) [ $ this -> controller_id ] [ $ this -> action_id ] ; list ( $ requestMethod , $ authType ) = $ restConfig ; $ response = $ this -> response ; $ this -> middleware [ 'authMiddleware' ] [ 'params' ] = [ 'rest_config' => $ restConfig , 'request' => $ this -> request , ] ; $ this -> middleware [ 'authMiddleware' ] [ 'failureCallback' ] = function ( ) use ( $ response ) { $ response -> response_unauthorized ( 401 ) ; } ; $ this -> middleware [ 'requestMethodFilter' ] [ 'params' ] = [ 'request_method' => $ requestMethod , 'request' => $ this -> request , ] ; $ this -> middleware [ 'requestMethodFilter' ] [ 'failureCallback' ] = function ( ) use ( $ response ) { $ response -> response_invalid_request ( 403 ) ; } ; if ( array_key_exists ( $ this -> action_id , $ this -> rateLimitActions ) ) { $ this -> middleware [ 'rateLimitFilter' ] [ 'params' ] = $ this -> rateLimitActions [ $ this -> action_id ] ; $ this -> middleware [ 'rateLimitFilter' ] [ 'failureCallback' ] = function ( ) use ( $ response ) { $ response -> response_invalid_request ( 403 ) ; } ; } } else { $ this -> response_invalid_request ( 403 ) ; } parent :: beforeAction ( ) ; }
Before Action Filter
55,788
public function getToc ( ContentInterface $ md_content , OutputFormatInterface $ formatter , array $ attributes = null ) { $ cfg_toc_max_level = $ this -> getConfigOrDefault ( 'toc_max_level' ) ; $ cfg_toc_title = $ this -> getConfigOrDefault ( 'toc_title' ) ; $ cfg_toc_title_level = $ this -> getConfigOrDefault ( 'toc_title_level' ) ; $ cfg_toc_id = $ this -> getConfigOrDefault ( 'toc_id' ) ; $ cfg_toc_class = $ this -> getConfigOrDefault ( 'toc_class' ) ; $ cfg_toc_item_title = $ this -> getConfigOrDefault ( 'toc_item_title' ) ; $ menu = $ md_content -> getMenu ( ) ; $ content = $ list_content = '' ; $ max_level = isset ( $ attributes [ 'max_level' ] ) ? $ attributes [ 'max_level' ] : $ cfg_toc_max_level ; if ( ! empty ( $ menu ) && count ( $ menu ) > 1 ) { $ depth = 0 ; $ current_level = null ; foreach ( $ menu as $ item_id => $ menu_item ) { $ _item_id = TemplateHelper :: getSafeIdString ( $ item_id ) ; if ( isset ( $ max_level ) && $ menu_item [ 'level' ] > $ max_level ) { continue ; } $ diff = $ menu_item [ 'level' ] - ( is_null ( $ current_level ) ? $ menu_item [ 'level' ] : $ current_level ) ; if ( $ diff > 0 ) { $ list_content .= str_repeat ( '<ul><li>' , $ diff ) ; } elseif ( $ diff < 0 ) { $ list_content .= str_repeat ( '</li></ul></li>' , - $ diff ) ; $ list_content .= '<li>' ; } else { if ( ! is_null ( $ current_level ) ) $ list_content .= '</li>' ; $ list_content .= '<li>' ; } $ depth += $ diff ; $ list_content .= $ formatter -> buildTag ( 'link' , $ menu_item [ 'text' ] , array ( 'href' => '#' . $ _item_id , 'title' => isset ( $ attributes [ 'toc_item_title' ] ) ? $ attributes [ 'toc_item_title' ] : $ cfg_toc_item_title , ) ) ; $ current_level = $ menu_item [ 'level' ] ; } if ( $ depth != 0 ) { $ list_content .= str_repeat ( '</ul></li>' , $ depth ) ; } $ content .= $ formatter -> buildTag ( 'title' , $ cfg_toc_title , array ( 'level' => isset ( $ attributes [ 'toc_title_level' ] ) ? $ attributes [ 'toc_title_level' ] : $ cfg_toc_title_level , 'id' => isset ( $ attributes [ 'toc_id' ] ) ? $ attributes [ 'toc_id' ] : $ cfg_toc_id , 'no-addon' => true ) ) ; $ content .= $ formatter -> buildTag ( 'unordered_list' , $ list_content , array ( 'class' => isset ( $ attributes [ 'class' ] ) ? $ attributes [ 'class' ] : $ cfg_toc_class , ) ) ; } return $ content ; }
Build a hierarchical menu
55,789
public function findManyByCategory ( ICategory $ category , $ limit = null ) { $ related = $ this -> modelClassInstance -> active ( ) -> where ( 'category_id' , $ category -> getId ( ) ) -> paginate ( $ limit ) ; return $ related ; }
Find many posts by category .
55,790
public function getWhere ( $ column , $ value , $ limit = null ) { $ related = $ this -> modelClassInstance -> where ( $ column , '=' , $ value ) ; return $ related ; }
Get where posts .
55,791
public function getRecent ( $ limit = null ) { $ related = $ this -> modelClassInstance -> active ( ) -> paginate ( $ limit ) ; return $ related ; }
Get recent posts .
55,792
public function getSticky ( $ limit = null ) { $ related = $ this -> modelClassInstance -> active ( ) -> where ( 'is_sticky' , true ) -> paginate ( $ limit ) ; return $ related ; }
Get sticky posts .
55,793
public function fetch ( $ how , $ orientation , $ offset ) { $ rows = $ this -> getRows ( ) ; if ( ! isset ( $ rows [ $ this -> current_index ] ) ) { return false ; } $ row = $ rows [ $ this -> current_index ] ; $ this -> current_index ++ ; return $ row -> format ( $ how , $ orientation , $ offset ) ; }
Formats the next row according to the formatting parameters provided .
55,794
public function fetchAll ( $ how , $ class_name , $ ctor_args ) { $ result = [ ] ; foreach ( $ this -> getRows ( ) as $ row ) { $ result [ ] = $ row -> format ( $ how , $ class_name , $ ctor_args ) ; } return $ result ; }
Formats and returns all the available rows in the result according to the formatting parameters provided
55,795
public function attachAtIndex ( $ index = null ) { if ( is_null ( $ index ) ) { return $ this -> attach ( ) ; } $ this -> getWye ( ) -> addResultAtIndex ( $ this , $ index ) ; return $ this ; }
Attach this result at the specified index . Without an index the result will be appended to the list of results .
55,796
protected function matchChoice ( ChoiceQuestion $ question , $ input ) { $ choices = $ question -> getChoices ( ) ; if ( isset ( $ choices [ $ input ] ) ) { return $ input ; } $ matchedValues = [ ] ; foreach ( $ choices as $ key => $ value ) { if ( stripos ( $ value , $ input ) === 0 ) { $ input = $ key ; $ matchedValues [ ] = $ value ; } } if ( count ( $ matchedValues ) > 1 ) { throw new InvalidArgumentException ( sprintf ( 'The provided answer is ambiguous. Value should be one of %s.' , implode ( ' or ' , $ matchedValues ) ) ) ; } return $ input ; }
Try to match choice by provided value .
55,797
function hasAuthenticated ( ) { try { if ( ! $ this -> identifier ( ) -> withIdentity ( ) -> isFulfilled ( ) ) return false ; } catch ( exLoadUserFailed $ e ) { $ this -> identifier ( ) -> signOut ( ) ; } catch ( exNotAuthenticated $ e ) { return false ; } return $ this -> identifier ( ) ; }
Has Authenticated And Identifier Exists
55,798
private function mergeMixins ( array $ toAdd ) { foreach ( $ toAdd as $ mixin ) { if ( ! isset ( $ this -> mixins [ $ mixin -> name ] ) ) { $ this -> mixins [ $ mixin -> name ] = $ mixin ; } } return $ this ; }
Merges mixins with this instance s mixins .
55,799
public function getThumbnailResponse ( $ width , $ image ) { if ( ! $ image instanceof Image ) { throw new \ LogicException ( "Not a valid image" ) ; } $ core = explode ( ";" , $ image -> getContent ( ) ) ; $ content = base64_decode ( substr ( $ core [ 1 ] , 7 ) ) ; $ thumbnail = new \ Imagick ( ) ; $ thumbnail -> readImageBlob ( $ content ) ; $ thumbnail -> scaleImage ( $ width , 0 ) ; return new Response ( $ thumbnail -> getImageBlob ( ) , 200 , array ( 'Content-Type' => $ image -> getMimeType ( ) ) ) ; }
Get Thumbnail Response