idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
600
private function getDncChannelName ( $ key ) { if ( ! $ this -> dncChannels ) { $ this -> dncChannels = $ this -> getContactModel ( ) -> getPreferenceChannels ( ) ; } if ( $ key ) { if ( isset ( $ this -> dncChannels [ $ key ] ) ) { return $ this -> dncChannels [ $ key ] ; } else { return ucwords ( $ key ) ; } } return...
Get all DNC Channels or one by key .
601
private function updateContact ( ) { $ this -> attribution = 0 ; if ( $ this -> test || ! $ this -> payloadModel ) { return ; } if ( ! $ this -> valid ) { return ; } try { $ this -> dispatchContextCreate ( ) ; $ updatedFields = false ; if ( method_exists ( $ this -> payloadModel , 'applyResponseMap' ) ) { $ updatedFiel...
Loop through the API Operation responses and find valid field mappings . Set the new values to the contact and log the changes thereof .
602
private function dispatchContextCapture ( ) { if ( $ this -> test || ! $ this -> valid || ! $ this -> payloadModel || Stat :: TYPE_CONVERTED !== $ this -> statType ) { return ; } $ campaign = $ this -> getCampaign ( ) ; $ event = new ContactLedgerContextEvent ( $ campaign , $ this -> contactClient , $ this -> statType ...
For situations where there is no entity saved but we still need to log a conversion .
603
private static function utf8_encode ( & $ mixed ) { if ( is_array ( $ mixed ) || is_object ( $ mixed ) ) { foreach ( $ mixed as & $ value ) { self :: utf8_encode ( $ value ) ; } } else { if ( is_string ( $ mixed ) ) { $ mixed = utf8_encode ( $ mixed ) ; } } }
Recursively encode via UTF8 .
604
public function getPreviousPayloadAuthTokensByContactClient ( $ contactClientId , $ operationId = null , $ test = false ) { $ result = [ ] ; $ q = $ this -> getEntityManager ( ) -> getConnection ( ) -> createQueryBuilder ( ) ; $ q -> select ( 'a.operation, a.type, a.field, a.val' ) -> from ( MAUTIC_TABLE_PREFIX . 'cont...
Gets all token key - value pairs for a contactClient that were previously captured by succesful auth requests and persisted for re - use .
605
public function setSettings ( $ settings = [ ] ) { $ original = $ this -> settings ; $ this -> mergeSettings ( $ settings , $ this -> settings ) ; if ( $ this -> settings != $ original ) { $ this -> client = new Client ( $ this -> settings ) ; } }
Establish a new Transport with the options provided if needed . Only options that match the keys of our defaults are to be supported .
606
private function mergeSettings ( $ settingsa , & $ settingsb ) { foreach ( $ settingsb as $ key => & $ value ) { if ( isset ( $ settingsa [ $ key ] ) ) { if ( is_array ( $ value ) ) { $ this -> mergeSettings ( $ settingsa [ $ key ] , $ value ) ; } else { $ value = $ settingsa [ $ key ] ; } } } }
Merge settings from an external source overriding internals by a nested array .
607
public function sanitizeEventFilter ( $ filters ) { if ( ! is_array ( $ filters ) ) { throw new \ InvalidArgumentException ( 'filters parameter must be an array' ) ; } if ( ! isset ( $ filters [ 'search' ] ) ) { $ filters [ 'search' ] = '' ; } if ( ! isset ( $ filters [ 'includeEvents' ] ) ) { $ filters [ 'includeEvent...
Makes sure that the event filter array is in the right format .
608
protected function getPlaces ( ContactClient $ contactClient ) { $ places = [ ] ; if ( $ contactClient -> getIpAddresses ( ) ) { foreach ( $ contactClient -> getIpAddresses ( ) as $ ip ) { if ( $ details = $ ip -> getIpDetails ( ) ) { if ( ! empty ( $ details [ 'latitude' ] ) && ! empty ( $ details [ 'longitude' ] ) ) ...
Get a list of places for the contactClient based on IP location .
609
final public function buffer ( ) : Promise { if ( $ this -> promise ) { return $ this -> promise ; } return $ this -> promise = call ( function ( ) { $ buffer = '' ; if ( $ this -> lastRead && null === yield $ this -> lastRead ) { return $ buffer ; } while ( null !== $ chunk = yield $ this -> stream -> read ( ) ) { $ b...
Buffers the entire message and resolves the returned promise then .
610
private function free ( ) { $ this -> readable = false ; if ( $ this -> deferred !== null ) { $ deferred = $ this -> deferred ; $ this -> deferred = null ; $ deferred -> resolve ( ) ; } Loop :: cancel ( $ this -> watcher ) ; if ( $ this -> immediateWatcher !== null ) { Loop :: cancel ( $ this -> immediateWatcher ) ; } ...
Nulls reference to resource marks stream unreadable and succeeds any pending read with null .
611
private function free ( ) { $ this -> resource = null ; $ this -> writable = false ; if ( ! $ this -> writes -> isEmpty ( ) ) { $ exception = new ClosedException ( "The socket was closed before writing completed" ) ; do { list ( , , $ deferred ) = $ this -> writes -> shift ( ) ; $ deferred -> fail ( $ exception ) ; } w...
Nulls reference to resource marks stream unwritable and fails any pending write .
612
public function includeFile ( $ filename , $ data = [ ] , $ context = [ ] ) { $ this -> tintin -> pushSharedData ( array_merge ( $ context , $ data ) ) ; $ data = $ this -> tintin -> getSharedData ( ) ; return $ this -> tintin -> render ( $ filename , $ data ) ; }
Include a file to compile
613
public function endStack ( ) { $ stacks = array_pop ( $ this -> stacks ) ; $ stacks = ( array ) $ stacks ; foreach ( $ stacks as $ block ) { $ content = $ this -> pushes [ $ block ] ; if ( is_null ( $ content ) ) { $ content = $ this -> tintin -> getCompiler ( ) -> compile ( ob_get_clean ( ) ) ; } $ this -> pushes [ $ ...
Closes the current flow
614
public function getStack ( $ name , $ default = null ) { if ( array_key_exists ( $ name , $ this -> pushes ) ) { return $ this -> tintin -> renderString ( $ this -> pushes [ $ name ] , [ '__tintin' => $ this -> tintin ] ) ; } return $ default ; }
Allows you to retrieve the contents of a stack
615
protected function compileIfStack ( $ expression ) { foreach ( [ 'UnLess' , 'If' , 'ElseIf' , 'ElseIfAlias' , 'Else' , 'EndIf' ] as $ token ) { $ out = $ this -> { 'compile' . $ token } ( $ expression ) ; if ( strlen ( $ out ) !== 0 ) { $ expression = $ out ; } } return $ expression ; }
Compile the if statement stack
616
protected function compileEchoStack ( $ expression ) { foreach ( [ 'RawEcho' , 'Echo' ] as $ token ) { $ out = $ this -> { 'compile' . $ token } ( $ expression ) ; if ( strlen ( $ out ) !== 0 ) { $ expression = $ out ; } } return $ expression ; }
Compile the echo statement concept
617
public function compile ( $ data ) { $ data = preg_split ( '/\n|\r\n/' , $ data ) ; foreach ( $ data as $ value ) { if ( strlen ( $ value ) > 0 ) { $ value = $ this -> compileToken ( $ value ) ; $ this -> result .= strlen ( $ value ) == 0 || $ value == ' ' ? trim ( $ value ) : $ value . "\n" ; } } return $ this -> rese...
Launch the compilation
618
private function compileToken ( $ value ) { foreach ( $ this -> tokens as $ token ) { $ out = $ this -> { 'compile' . $ token } ( $ value ) ; if ( $ token == 'Comments' ) { if ( strlen ( $ out ) == 0 ) { return "" ; } } if ( strlen ( $ out ) !== 0 ) { $ value = $ out ; } } return $ value ; }
Compile All define token
619
private function resetCompilatorAccumulator ( ) { $ result = $ this -> result . implode ( "\n" , $ this -> footer ) ; $ this -> result = '' ; $ this -> footer = [ ] ; return $ result ; }
Reset Compilation accumulatior
620
protected function compileExtendsStack ( $ expression ) { foreach ( [ 'Block' , 'EndBlock' , 'Include' , 'Inject' , 'Extends' ] as $ token ) { $ out = $ this -> { 'compile' . $ token } ( $ expression ) ; if ( strlen ( $ out ) !== 0 ) { $ expression = $ out ; } } return $ expression ; }
Compile the inherit concept statement
621
public function render ( $ template , array $ data = [ ] ) { if ( is_null ( $ this -> loader ) ) { return $ this -> renderString ( $ template , $ data ) ; } if ( ! $ this -> loader -> exists ( $ template ) ) { $ this -> loader -> failLoading ( $ template . ' not found' ) ; } $ this -> pushSharedData ( $ data ) ; $ __ti...
Make template rendering
622
public function renderString ( $ template , array $ data = [ ] ) { return $ this -> executePlainRendering ( trim ( $ this -> compiler -> compile ( $ template ) ) , array_merge ( $ data , [ '__tintin' => $ this ] ) ) ; }
Compile simple template code
623
private function executePlainRendering ( $ content , $ data ) { $ this -> obFlushAndStar ( ) ; extract ( $ data ) ; $ filename = $ this -> createTmpFile ( $ content ) ; require $ filename ; @ unlink ( $ filename ) ; return $ this -> obGetContent ( ) ; }
Execute plain rendering code
624
private function createTmpFile ( $ content ) { $ tmp_dir = sys_get_temp_dir ( ) . '/__tintin' ; if ( ! is_dir ( $ tmp_dir ) ) { mkdir ( $ tmp_dir , 0777 ) ; } $ file = $ tmp_dir . '/' . md5 ( microtime ( true ) ) . '.php' ; file_put_contents ( $ file , $ content ) ; return $ file ; }
Create tmp compile file
625
protected function compileLoopStack ( $ expression ) { foreach ( $ this -> getLoopStack ( ) as $ token ) { $ out = $ this -> { 'compile' . $ token } ( $ expression ) ; if ( strlen ( $ out ) !== 0 ) { $ expression = $ out ; } } return $ expression ; }
Compile the loop statement stack
626
private function compileBreaker ( $ expression , $ lexic , $ o_lexic ) { $ output = preg_replace_callback ( "/($lexic *(\(.+?\))|$lexic)/s" , function ( $ match ) use ( $ lexic , $ o_lexic ) { array_shift ( $ match ) ; if ( trim ( $ match [ 0 ] ) == $ lexic ) { return "<?php $o_lexic; ?>" ; } return "<?php if {$match[1...
Compile the loop breaker statement
627
public function publish ( $ assetFolder ) { $ widgetSourceAssetPath = dirname ( Utility :: getClassPath ( $ this -> widget ) ) . "/" . $ assetFolder ; if ( ! is_dir ( $ widgetSourceAssetPath ) ) { throw new \ Exception ( "Widget's assets folder is not existed" ) ; } $ widgetSourceAssetPath = Utility :: standardizePathS...
Publish an asset folder to public place
628
public function receiveMeta ( $ metaData , $ source ) { $ this -> streamingSource = $ source ; $ this -> metaData = $ metaData ; $ this -> startProcess -> receiveMeta ( $ metaData , $ this ) ; }
Receive the meta data from source
629
static function guessType ( $ value ) { $ map = array ( "float" => "number" , "double" => "number" , "int" => "number" , "integer" => "number" , "bool" => "number" , "numeric" => "number" , "string" => "string" , ) ; $ type = strtolower ( gettype ( $ value ) ) ; foreach ( $ map as $ key => $ value ) { if ( strpos ( $ t...
Try to get type of a value
630
static function format ( $ value , $ format ) { $ f = Utility :: get ( $ format , "format" , true ) ; if ( $ f === false ) { return $ value ; } $ type = Utility :: get ( $ format , "type" , "unknown" ) ; switch ( $ type ) { case "number" : $ decimals = Utility :: get ( $ format , "decimals" , 0 ) ; $ dec_point = Utilit...
Format the value with provided format settings
631
static function mark_js_function ( & $ obj , & $ marks = array ( ) ) { foreach ( $ obj as $ k => & $ v ) { switch ( gettype ( $ v ) ) { case "object" : case "array" : Utility :: mark_js_function ( $ v , $ marks ) ; break ; case "string" : $ tsv = trim ( strtolower ( $ v ) ) ; if ( strpos ( $ tsv , "function" ) === 0 &&...
Traverse through the structure of object and find the js function
632
static function jsonEncode ( $ object , $ option = 0 ) { $ marks = Utility :: mark_js_function ( $ object ) ; $ text = json_encode ( $ object , $ option ) ; foreach ( $ marks as $ i => $ js ) { $ text = str_replace ( "\"--js($i)\"" , $ js , $ text ) ; } return $ text ; }
Get the json of an object
633
static function isAssoc ( $ arr ) { if ( gettype ( $ arr ) != "array" ) { return false ; } if ( $ arr === null || $ arr === array ( ) ) { return false ; } if ( array_keys ( $ arr ) === range ( 0 , count ( $ arr ) - 1 ) ) { return false ; } return true ; }
Get wether an array is an associate array
634
static function get ( $ arr , $ keys , $ default = null ) { if ( ! is_array ( $ arr ) ) { return $ default ; } if ( is_array ( $ keys ) and count ( $ keys ) > 0 ) { foreach ( $ keys as $ key ) { $ arr = self :: get ( $ arr , $ key , $ default ) ; } return $ arr ; } if ( is_string ( $ keys ) || is_int ( $ keys ) ) { ret...
Get value from array with keys return default if not found
635
static function init ( & $ arr , $ key , $ default = null ) { if ( ! isset ( $ arr [ $ key ] ) ) { $ arr [ $ key ] = $ default ; } return $ arr [ $ key ] ; }
Init an key value inside an array
636
static function getArray ( $ arr , $ key , $ default = array ( ) ) { $ value = Utility :: get ( $ arr , $ key ) ; return ( $ value != null ) ? explode ( ',' , $ value ) : $ default ; }
Get array if the value inside an array is a string
637
static function filterIn ( $ arr , $ keys ) { $ keys = explode ( "," , $ keys ) ; $ result = array ( ) ; foreach ( $ arr as $ key => $ value ) { if ( in_array ( $ key , $ keys ) ) { $ result [ $ key ] = $ value ; } } return $ result ; }
Get only some of the keys from an array
638
static function strReplace ( $ str , $ params ) { foreach ( $ params as $ k => $ v ) { $ str = str_replace ( $ k , $ v , $ str ) ; } return $ str ; }
A mass string replace with parameters
639
static function str_replace_first ( $ from , $ to , $ content ) { $ from = '/' . preg_quote ( $ from , '/' ) . '/' ; return preg_replace ( $ from , $ to , $ content , 1 ) ; }
Return string with replaced first occurerence only
640
static function getDocumentRoot ( ) { $ old_way = str_replace ( "\\" , "/" , realpath ( $ _SERVER [ "DOCUMENT_ROOT" ] ) ) ; $ script_filename = str_replace ( "\\" , "/" , realpath ( $ _SERVER [ "SCRIPT_FILENAME" ] ) ) ; $ script_name = str_replace ( "\\" , "/" , realpath ( $ _SERVER [ "SCRIPT_NAME" ] ) ) ; $ new_way = ...
Get the doument root
641
static function getSymbolicPath ( $ realpath ) { $ root = $ _SERVER [ 'DOCUMENT_ROOT' ] ; $ script = $ _SERVER [ 'SCRIPT_FILENAME' ] ; $ root = str_replace ( '\\' , '/' , $ root ) ; $ script = str_replace ( '\\' , '/' , $ script ) ; $ realpath = str_replace ( '\\' , '/' , $ realpath ) ; $ dir = str_replace ( $ root , '...
Get the dirname
642
public function query ( $ query , $ sqlParams = null ) { $ this -> query = ( string ) $ query ; if ( $ sqlParams != null ) { $ this -> sqlParams = $ sqlParams ; } return $ this ; }
Set the query and params
643
protected function prepareParams ( $ query , $ sqlParams ) { if ( empty ( $ sqlParams ) ) { $ sqlParams = [ ] ; } uksort ( $ sqlParams , function ( $ k1 , $ k2 ) { return strlen ( $ k1 ) < strlen ( $ k2 ) ; } ) ; $ resultQuery = $ query ; $ paramNum = 0 ; foreach ( $ sqlParams as $ paName => $ paValue ) { if ( gettype ...
Prepare SQL statement
644
protected function typeToPDOParamType ( $ type ) { switch ( $ type ) { case "boolean" : return PDO :: PARAM_BOOL ; case "integer" : return PDO :: PARAM_STR ; case "NULL" : return PDO :: PARAM_NULL ; case "resource" : return PDO :: PARAM_LOB ; case "double" : case "string" : default : return PDO :: PARAM_STR ; } }
Convert type to PdoParamType
645
protected function clientSideReady ( $ name = null ) { if ( $ name == null && $ this -> onReady != null ) { echo "(" . $ this -> onReady . ")(" . $ this -> name . ");" ; } else if ( $ this -> onReady != null ) { if ( $ name == "" ) { echo "(" . $ this -> onReady . ")();" ; } else { echo "(" . $ this -> onReady . ")(" ....
Render javascript code to implement user s custom script when widget is ready at client - side
646
protected function attachResourceToEnd ( & $ destination , $ attachment ) { for ( $ i = count ( $ destination ) - 1 ; $ i > - 1 ; $ i -- ) { if ( is_array ( $ destination [ $ i ] ) ) { if ( $ this -> attachResourceToEnd ( $ destination [ $ i ] , $ attachment ) ) { return true ; } } } array_push ( $ destination , $ atta...
Attach an resource to end of queue line
647
protected function convertHierachicalResources ( & $ resources ) { foreach ( $ resources as & $ resource ) { if ( gettype ( $ resource ) == "string" ) { $ resource = $ this -> getAssetManager ( ) -> getAssetUrl ( $ resource ) ; } else if ( gettype ( $ resource ) == "array" ) { $ this -> convertHierachicalResources ( $ ...
The resources settings from short form will be converted to long form which include full url to each resource
648
protected function useAutoName ( $ prefix = "widget" ) { if ( $ this -> name == null ) { $ this -> name = $ prefix . Utility :: getUniqueId ( ) ; } }
Use by descendant widget class to take name settings
649
protected function useDataSource ( ) { $ args = func_get_args ( ) ; $ dataSource = Utility :: get ( $ this -> params , "dataSource" , Utility :: get ( $ this -> params , "dataStore" ) ) ; $ this -> dataStore = $ this -> standardizeDataSource ( $ dataSource , $ args ) ; }
Use by descendant widget class to initiate the datasource
650
protected function useLanguage ( ) { $ this -> language = Utility :: get ( $ this -> params , "language" ) ; if ( $ this -> language !== null ) { if ( gettype ( $ this -> language ) == "string" ) { $ languageFile = $ this -> getWidgetFolder ( ) . "/languages/" . Utility :: getClassName ( $ this ) . "." . strtolower ( $...
Register using language settings for widget
651
public function render ( ) { if ( $ this -> report -> fireEvent ( "OnBeforeWidgetRender" , $ this ) ) { $ type = str_replace ( '\\' , '/' , get_class ( $ this ) ) ; echo "<krwidget widget-name='$this->name' widget-type='$type'" . ( $ this -> themeCssClass ? " class='$this->themeCssClass'" : "" ) . ">" ; $ this -> onRen...
Render this widget
652
protected function template ( $ template = null , $ variables = null , $ return = false ) { if ( ! $ template ) { $ template = Utility :: getClassName ( $ this ) ; } else if ( gettype ( $ template ) == "array" ) { if ( gettype ( $ variables ) == "boolean" ) { $ return = $ variables ; } $ variables = $ template ; $ temp...
Loading template and inject parameters
653
static function create ( $ params , $ return = false ) { $ class = get_called_class ( ) ; $ component = new $ class ( $ params ) ; if ( $ return ) { ob_start ( ) ; $ component -> render ( ) ; return ob_get_clean ( ) ; } else { $ component -> render ( ) ; } }
Create widget object
654
protected function onInit ( ) { $ this -> useDataSource ( ) ; $ this -> useAutoName ( "gchart" ) ; $ this -> clientEvents = Utility :: get ( $ this -> params , "clientEvents" , array ( ) ) ; $ this -> columns = Utility :: get ( $ this -> params , "columns" , null ) ; $ this -> options = Utility :: get ( $ this -> param...
Return the resource settings for table
655
protected function getColumnSettings ( ) { $ meta = $ this -> dataStore -> meta ( ) ; $ columns = array ( ) ; if ( $ this -> columns != null ) { foreach ( $ this -> columns as $ cKey => $ cValue ) { if ( gettype ( $ cValue ) == "array" ) { $ columns [ $ cKey ] = array_merge ( $ meta [ "columns" ] [ $ cKey ] , $ cValue ...
Improve the column settings
656
protected function formatValue ( $ value , $ format , $ row = null ) { $ formatValue = Utility :: get ( $ format , "formatValue" , null ) ; if ( is_string ( $ formatValue ) ) { eval ( '$fv="' . str_replace ( '@value' , '$value' , $ formatValue ) . '";' ) ; return $ fv ; } else if ( is_callable ( $ formatValue ) ) { ret...
Return the formatted value
657
protected function onInit ( ) { if ( is_array ( $ this -> params ) ) { foreach ( $ this -> params as $ cName => $ cMap ) { $ cFunc = Utility :: get ( $ cMap , "{func}" ) ; if ( is_callable ( $ cFunc ) ) { $ this -> mapFuncs [ $ cName ] = $ cFunc ; } } } }
Handle on initation
658
public function receiveMeta ( $ metaData , $ source ) { if ( $ source === $ this -> container [ 0 ] [ "source" ] ) { $ this -> container [ 0 ] [ "meta" ] = $ metaData ; } else { $ this -> container [ 1 ] [ "meta" ] = $ metaData ; } if ( $ this -> container [ 0 ] [ "meta" ] && $ this -> container [ 1 ] [ "meta" ] ) { $ ...
Handle on meta data received
659
protected function newClientDate ( $ value , $ meta ) { $ format = Utility :: get ( $ meta , "format" ) ; $ type = Utility :: get ( $ meta , "type" ) ; if ( $ format == null ) { switch ( $ type ) { case "date" : $ format = "Y-m-d" ; $ toFormat = "Y,(n-1),d" ; break ; case "time" : $ format = "H:i:s" ; $ toFormat = "0,0...
Convert server - side date to client - side format
660
protected function generateGroups ( $ meta ) { if ( $ this -> group ) { $ result = array ( ) ; $ sorts = array ( ) ; foreach ( $ this -> group as $ by => $ settings ) { $ sorts [ $ by ] = Utility :: get ( $ settings , "sort" , "asc" ) ; } $ sorts = array_merge ( $ sorts , $ this -> sorting ) ; $ this -> dataStore -> so...
Generate groups for table grouping
661
protected function renderRowGroup ( $ groups , $ index , $ colspan ) { if ( $ groups && isset ( $ groups [ $ index ] ) ) { foreach ( $ groups [ $ index ] as $ grow ) { if ( $ this -> paging ) { $ grow [ 3 ] = "display:none;" . $ grow [ 3 ] ; } echo "<tr from='$grow[0]' to='$grow[1]' class='row-group" . ( $ grow [ 4 ] ?...
Echo the row group content in html
662
public function onRender ( ) { $ meta = $ this -> dataStore -> meta ( ) ; $ showColumnKeys = array ( ) ; if ( $ this -> columns == array ( ) ) { if ( $ row = $ this -> dataStore [ 0 ] ) { $ showColumnKeys = array_keys ( $ row ) ; } else if ( count ( $ meta [ "columns" ] ) > 0 ) { $ showColumnKeys = array_keys ( $ meta ...
Handle on widget rendering
663
public function receiveMeta ( $ metaData , $ source ) { $ this -> streamingSource = $ source ; $ this -> newMeta = $ this -> metaData = $ metaData ; $ func = Util :: get ( $ this -> params , '{meta}' , null ) ; if ( is_callable ( $ func ) ) { $ this -> newMeta = $ func ( $ metaData ) ; } }
Handle on data recieved
664
protected function to2DArray ( $ arr ) { if ( empty ( $ arr ) || ! is_array ( $ arr ) ) { return [ ] ; } if ( count ( $ arr ) == count ( $ arr , COUNT_RECURSIVE ) ) { return [ $ arr ] ; } return $ arr ; }
Convert to 2D array
665
protected function escape ( $ str ) { if ( is_string ( $ str ) OR ( is_object ( $ str ) && method_exists ( $ str , '__toString' ) ) ) { return "'" . $ this -> escapeStr ( $ str ) . "'" ; } elseif ( is_bool ( $ str ) ) { return ( $ str === false ) ? 0 : 1 ; } elseif ( $ str === null ) { return 'NULL' ; } return $ str ; ...
Escape value for SQL safe
666
public function __constructSubReport ( ) { $ this -> registerEvent ( "OnInit" , function ( ) { $ params = array_merge ( $ this -> params , $ _POST ) ; if ( isset ( $ params [ "@subReport" ] ) ) { $ name = $ params [ "@subReport" ] ; unset ( $ params [ "@subReport" ] ) ; $ settings = $ this -> settings ( ) ; $ subReport...
Initiate sub report
667
public function subReport ( $ name , $ params = array ( ) ) { $ subReports = Utility :: get ( $ this -> reportSettings , "subReports" ) ; $ class = Utility :: get ( $ subReports , $ name ) ; if ( $ class != null ) { $ params [ "@reportName" ] = $ name ; $ r = new $ class ( $ params ) ; echo "<sub-report id='$name' name...
Render a sub report inside report
668
protected function onInit ( ) { $ username = Util :: get ( $ this -> params , "username" , "" ) ; $ password = Util :: get ( $ this -> params , "password" , "" ) ; $ connString = Util :: get ( $ this -> params , "connectionString" , "" ) ; $ key = md5 ( $ username . $ password . $ connString ) ; if ( isset ( OracleData...
Called for initiation
669
static function processQuery ( $ query , $ queryParams ) { $ search = Util :: get ( $ queryParams , 'search' , '1=1' ) ; $ searchSql = "WHERE $search" ; $ order = Util :: get ( $ queryParams , 'order' , '' ) ; $ orderSql = ! empty ( $ order ) ? "ORDER BY $order" : "" ; $ start = ( int ) Util :: get ( $ queryParams , 's...
Process query to additional condition
670
public function colorScheme ( $ key = null ) { $ all = $ this -> allColorSchemes ( ) ; $ allKeys = array_keys ( $ all ) ; if ( count ( $ allKeys ) > 0 ) { if ( $ key && isset ( $ all [ strtolower ( $ key ) ] ) ) { return $ all [ strtolower ( $ key ) ] ; } return $ all [ $ allKeys [ 0 ] ] ; } return null ; }
Get color scheme
671
public function doesSupport ( $ widget ) { if ( gettype ( $ widget ) != "string" ) { $ widget = get_class ( $ widget ) ; } return isset ( $ this -> themeWidgets ( ) [ $ widget ] ) ; }
Whether theme support a widget
672
public function getWidgetResourcesFor ( $ widget ) { $ resources = array ( "js" => array ( ) , "css" => array ( ) , "replacingCss" => array ( ) , "replacingJs" => array ( ) , ) ; if ( gettype ( $ widget ) != "string" ) { $ widget = get_class ( $ widget ) ; } $ settings = $ this -> themeWidgets ( ) [ $ widget ] ; if ( i...
Return resources information of an widget
673
protected function addingAssetUrl ( $ assetUrl , $ resources ) { foreach ( $ resources as & $ resource ) { if ( gettype ( $ resource ) == "string" ) { $ resource = $ assetUrl . "/" . $ resource ; } else if ( gettype ( $ resource ) == "array" ) { $ resource = $ this -> addingAssetUrl ( $ assetUrl , $ resource ) ; } } re...
Get resources in short format and return full url to each component of resources
674
public function meta ( $ metaData = null ) { if ( $ metaData ) { $ this -> metaData = $ metaData ; return $ this ; } else { return $ this -> metaData ; } }
Get or set the meta data of datastore
675
public function data ( $ rows = null ) { if ( $ rows !== null ) { $ this -> rows = $ rows ; return $ this ; } else { return $ this -> rows ; } }
Get or set data inside DataStore
676
public function get ( $ index = 0 , $ colName = null ) { if ( isset ( $ this -> rows [ $ index ] ) ) { if ( $ colName !== null ) { if ( isset ( $ this -> rows [ $ index ] [ $ colName ] ) ) { return $ this -> rows [ $ index ] [ $ colName ] ; } } else { return $ this -> rows [ $ index ] ; } } return null ; }
Return a data row at index or single value at column name
677
public function breakGroup ( $ key , $ func ) { $ data = array ( ) ; $ start = 0 ; foreach ( $ this -> rows as $ i => $ row ) { if ( ! isset ( $ oldValue ) ) { $ oldValue = $ row [ $ key ] ; } if ( $ row [ $ key ] == $ oldValue ) { $ oldValue = $ row [ $ key ] ; array_push ( $ data , $ row ) ; } else { $ func ( new Dat...
Break datastore into smaller group by specific column value
678
public function top ( $ num , $ offset = 0 ) { $ count = $ this -> countData ( ) ; $ result = array ( ) ; for ( $ i = $ offset ; $ i < $ num + $ offset && $ i < $ count ; $ i ++ ) { array_push ( $ result , $ this -> rows [ $ i ] ) ; } return new DataStore ( $ result , $ this -> metaData ) ; }
Return top number of rows
679
public function topByPercent ( $ num ) { $ count = $ this -> countData ( ) ; return $ this -> top ( round ( $ num * $ count / 100 ) ) ; }
Return top percent of row
680
public function bottom ( $ num ) { $ count = $ this -> countData ( ) ; $ result = array ( ) ; $ start = ( $ count > $ num ) ? $ count - $ num : 0 ; for ( $ i = $ start ; $ i < $ count ; $ i ++ ) { array_push ( $ result , $ this -> rows [ $ i ] ) ; } return new DataStore ( $ result , $ this -> metaData ) ; }
Return bottom rows of dataset
681
public function bottomByPercent ( $ num ) { $ count = $ this -> countData ( ) ; return $ this -> bottom ( round ( $ num * $ count / 100 ) ) ; }
Return the bottom rows by percent
682
public function sum ( $ colName ) { $ sum = 0 ; foreach ( $ this -> rows as $ row ) { $ sum += $ row [ $ colName ] ; } return $ sum ; }
Return the sum of a field
683
public function min ( $ colName ) { $ min = INF ; foreach ( $ this -> rows as $ row ) { if ( $ min > $ row [ $ colName ] ) { $ min = $ row [ $ colName ] ; } } return $ min ; }
Return the min value of a field
684
public function max ( $ colName ) { $ max = - INF ; foreach ( $ this -> rows as $ row ) { if ( $ max < $ row [ $ colName ] ) { $ max = $ row [ $ colName ] ; } } return $ max ; }
Return the max of a field
685
public function avg ( $ colName ) { if ( $ this -> countData ( ) > 0 ) { return $ this -> sum ( $ colName ) / $ this -> countData ( ) ; } return false ; }
Return the average value of a field
686
public function process ( $ process ) { $ ds = new DataStore ; $ process -> pipe ( $ ds ) ; $ top_process = $ process ; while ( $ top_process -> previous ( ) != null ) { $ top_process = $ top_process -> previous ( ) ; } $ top_process -> receiveMeta ( $ this -> metaData , $ this ) ; $ top_process -> startInput ( $ this ...
Pipe rows of data to process and get result
687
public function each ( $ cb ) { foreach ( $ this -> rows as $ index => $ row ) { $ result = $ cb ( $ row , $ index ) ; if ( is_array ( $ result ) ) { $ this -> rows [ $ index ] = $ result ; } else if ( $ result === false ) { break ; } } return $ this ; }
Loop through each rows of data set
688
public function except ( ) { $ cols = func_get_args ( ) ; $ dstore = new DataStore ; foreach ( $ this -> rows as $ row ) { foreach ( $ cols as $ col ) { if ( isset ( $ row [ $ col ] ) ) { unset ( $ row [ $ col ] ) ; } } $ dstore -> append ( $ row ) ; } $ columnsMeta = Utility :: get ( $ this -> metaData , "columns" ) ;...
Return new datastore with all columns except some
689
public function only ( ) { $ cols = func_get_args ( ) ; $ dstore = new DataStore ; foreach ( $ this -> rows as $ row ) { $ new_row = array ( ) ; foreach ( $ cols as $ col ) { $ new_row [ $ col ] = $ row [ $ col ] ; } $ dstore -> push ( $ new_row ) ; } $ columnsMeta = Utility :: get ( $ this -> metaData , "columns" ) ; ...
Get new datastore containing some of the columns
690
public function filterByFunc ( $ cb ) { $ dstore = new DataStore ; $ dstore -> meta ( $ this -> metaData ) ; foreach ( $ this -> rows as $ index => $ row ) { if ( $ cb ( $ row , $ index ) === true ) { $ dstore -> append ( $ row ) ; } } return $ dstore ; }
Get filtered results by function
691
public function first ( $ cb = null ) { if ( $ cb == null ) { return $ this -> isNotEmpty ( ) ? $ this -> rows [ 0 ] : null ; } else { foreach ( $ this -> rows as $ index => $ row ) { if ( $ cb ( $ row , $ index ) === true ) { return $ row ; } } } return null ; }
Return a first row meet a condition defined by callback function
692
public function last ( $ cb = null ) { if ( $ cb == null ) { return $ this -> isNotEmpty ( ) ? $ this -> rows [ $ this -> count ( ) - 1 ] : null ; } else { $ count = $ this -> count ( ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { if ( $ cb ( $ this -> rows [ $ count - $ i ] , $ count - $ i ) === true ) { return $ this...
Return the last row that meets a condition set by callback function
693
public function mode ( $ colName ) { $ counts = array ( ) ; foreach ( $ this -> rows as $ row ) { $ counts [ $ row [ $ colName ] ] = isset ( $ counts [ $ row [ $ colName ] ] ) ? $ counts [ $ row [ $ colName ] ] + 1 : 1 ; } arsort ( $ counts ) ; $ list = array_keys ( $ counts ) ; return $ list [ 0 ] ; }
Return the mode value of a field
694
public function pluck ( $ colName ) { $ result = array ( ) ; foreach ( $ this -> rows as $ row ) { array_push ( $ result , $ row [ $ colName ] ) ; } return $ result ; }
Return all value of a column in array
695
public function reject ( $ cb ) { $ dstore = new DataStore ; $ dstore -> meta ( $ this -> metaData ) ; foreach ( $ this -> rows as $ index => $ row ) { if ( $ cb ( $ row , $ index ) === false ) { $ dstore -> append ( $ row ) ; } } return $ dstore ; }
Reject some rows that meets condition
696
public function slice ( $ offset , $ length = null ) { return new DataStore ( array_slice ( $ this -> rows , $ offset , $ length ) , $ this -> metaData ) ; }
Get slice of data
697
public function sort ( $ sorts ) { usort ( $ this -> rows , function ( $ a , $ b ) use ( $ sorts ) { $ cmp = 0 ; foreach ( $ sorts as $ sort => $ direction ) { if ( is_string ( $ direction ) ) { $ cmp = is_numeric ( $ a [ $ sort ] ) && is_numeric ( $ b [ $ sort ] ) ? $ a [ $ sort ] - $ b [ $ sort ] : strcmp ( $ a [ $ s...
Sort the rows of data
698
public function sortKeys ( ) { if ( $ this -> isNotEmpty ( ) ) { foreach ( $ this -> rows as & $ row ) { ksort ( $ row ) ; } } return $ this ; }
Sort asc data rows by column name
699
public function sortKeysDesc ( ) { if ( $ this -> isNotEmpty ( ) ) { foreach ( $ this -> rows as & $ row ) { krsort ( $ row ) ; } } return $ this ; }
Sort desc data rows by column name