idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
12,500
public function afterFind ( $ results = array ( ) , $ primary = false ) { if ( $ results ) { foreach ( $ results as & $ result ) { if ( isset ( $ result [ 'date' ] ) ) { if ( $ time = DateTime :: createFromFormat ( DateTime :: RFC822 , $ result [ 'date' ] . 'C' ) ) { $ result [ 'date' ] = $ time -> format ( 'Y-m-d H:i:...
Format the date a certain way .
12,501
public function startOfWeek ( \ DateTime $ datetime ) { $ diffInDays = intval ( $ datetime -> format ( 'N' ) ) - 1 ; $ intervalSpec = sprintf ( 'P%sD' , $ diffInDays ) ; $ datetime -> sub ( new \ DateInterval ( $ intervalSpec ) ) ; }
Sets time for the start of a week .
12,502
public function endOfWeek ( \ DateTime $ datetime ) { $ diffInDays = 7 - intval ( $ datetime -> format ( 'N' ) ) ; $ intervalSpec = sprintf ( 'P%sD' , $ diffInDays ) ; $ datetime -> add ( new \ DateInterval ( $ intervalSpec ) ) ; }
Sets time for the end of a week .
12,503
public function startOfMonth ( \ DateTime $ datetime ) { $ year = $ datetime -> format ( 'Y' ) ; $ month = $ datetime -> format ( 'm' ) ; $ datetime -> setDate ( $ year , $ month , 1 ) ; }
Sets time for the start of a month .
12,504
public function endOfMonth ( \ DateTime $ datetime ) { $ year = $ datetime -> format ( 'Y' ) ; $ month = $ datetime -> format ( 'm' ) ; $ day = $ datetime -> format ( 't' ) ; $ datetime -> setDate ( $ year , $ month , $ day ) ; }
Sets time for the end of a month .
12,505
public static function createFromFormat ( $ format , $ time , \ DateTimeZone $ timezone = null ) { $ datetime = is_null ( $ timezone ) ? \ DateTime :: createFromFormat ( $ format , $ time ) : \ DateTime :: createFromFormat ( $ format , $ time , $ timezone ) ; return new static ( $ datetime ) ; }
Creates a DateTime object from the given format .
12,506
public static function create ( $ year , $ month = '01' , $ day = '01' , $ hour = '00' , $ minute = '00' , $ second = '00' , \ DateTimeZone $ timezone = null ) { $ time = sprintf ( '%04s-%02s-%02s %02s:%02s:%02s' , $ year , $ month , $ day , $ hour , $ minute , $ second ) ; return static :: createFromFormat ( 'Y-m-d H:...
Creates a DateTime object .
12,507
public static function createFromDate ( $ year , $ month = '01' , $ day = '01' , \ DateTimeZone $ timezone = null ) { return static :: create ( $ year , $ month , $ day , '00' , '00' , '00' , $ timezone ) ; }
Creates a DateTime object with time of the midnight .
12,508
public static function createFromTime ( $ hour = '00' , $ minute = '00' , $ second = '00' , \ DateTimeZone $ timezone = null ) { return static :: create ( date ( 'Y' ) , date ( 'm' ) , date ( 'd' ) , $ hour , $ minute , $ second , $ timezone ) ; }
Creates a DateTime object with date of today .
12,509
public function add ( DateInterval $ interval ) { return $ this -> modify ( function ( \ DateTime $ datetime ) use ( $ interval ) { $ datetime -> add ( $ interval -> getDateInterval ( ) ) ; } ) ; }
Returns a new DateTime object by adding an interval to the current one .
12,510
public function sub ( DateInterval $ interval ) { return $ this -> modify ( function ( \ DateTime $ datetime ) use ( $ interval ) { $ datetime -> sub ( $ interval -> getDateInterval ( ) ) ; } ) ; }
Returns a new DateTime object by subtracting an interval from the current one .
12,511
protected function getStrategy ( ) { if ( is_null ( $ this -> strategy ) ) { $ this -> strategy = new Strategy \ DateTimeStrategy ; } return $ this -> strategy ; }
Gets the Strategy implementation .
12,512
private function calc ( $ value , $ format ) { $ value = intval ( $ value ) ; $ spec = sprintf ( $ format , abs ( $ value ) ) ; return $ value > 0 ? $ this -> add ( new DateInterval ( $ spec ) ) : $ this -> sub ( new DateInterval ( $ spec ) ) ; }
Creates a DateTime by adding or subtacting interval .
12,513
private function fixMonth ( DateTime $ result ) { if ( $ result -> format ( 'd' ) != $ this -> format ( 'd' ) ) { $ result = $ result -> subMonths ( 1 ) ; $ result -> datetime -> setDate ( $ result -> format ( 'Y' ) , $ result -> format ( 'm' ) , $ result -> format ( 't' ) ) ; } return $ result ; }
If a day has changed sets the date on the last day of the previous month .
12,514
public function core ( ) { $ key = isset ( $ this -> params [ 'key' ] ) ? $ this -> params [ 'key' ] : null ; $ config = isset ( $ this -> params [ 'config' ] ) ? $ this -> params [ 'config' ] : 'default' ; if ( $ key ) { $ this -> out ( sprintf ( 'Clearing %s in %s...' , $ key , $ config ) ) ; Cache :: delete ( $ key ...
Delete CakePHP cache .
12,515
public function setParent ( CookieJar $ parent = null ) { $ this -> parent = $ parent ; if ( $ this -> parent ) { $ this -> enableParent ( ) ; $ this -> parent -> setChild ( $ this ) ; } else { $ this -> disableParent ( ) ; } return $ this ; }
Set the parent of this cookie jar to support inheritance
12,516
public function has ( $ key ) { if ( ! isset ( $ this -> jar [ $ key ] ) or $ this -> jar [ $ key ] -> isDeleted ( ) ) { if ( ! $ this -> parentEnabled or ! $ this -> parent -> has ( $ key ) ) { return false ; } } return true ; }
Check if we have this cookie in the jar
12,517
public function delete ( $ key ) { if ( isset ( $ this -> jar [ $ key ] ) and ! $ this -> jar [ $ key ] -> isDeleted ( ) ) { return $ this -> jar [ $ key ] -> delete ( ) ; } elseif ( $ this -> has ( $ key ) ) { return $ this -> parent -> delete ( $ key ) ; } return false ; }
Remove a cookie from the cookie jar
12,518
public function get ( $ key , $ default = null ) { if ( isset ( $ this -> jar [ $ key ] ) and ! $ this -> jar [ $ key ] -> isDeleted ( ) ) { return $ this -> jar [ $ key ] -> getValue ( ) ; } elseif ( $ this -> has ( $ key ) ) { return $ this -> parent -> get ( $ key , $ default ) ; } return $ default ; }
Get a cookie s value from the cookie jar
12,519
public function send ( ) { $ result = true ; foreach ( $ this -> jar as $ cookie ) { if ( ! $ cookie -> send ( ) ) { $ result = false ; } } foreach ( $ this -> children as $ cookie ) { if ( ! $ cookie -> send ( ) ) { $ result = false ; } } return $ result ; }
Send all cookies to the client
12,520
protected function getJar ( ) { if ( $ this -> parentEnabled ) { return array_merge ( $ this -> parent -> getJar ( ) , $ this -> jar ) ; } else { return $ this -> jar ; } }
Allows the ArrayIterator to fetch parent data
12,521
public function setChild ( CookieJar $ child ) { if ( ! in_array ( $ child , $ this -> children ) ) { $ this -> children [ ] = $ child ; } }
Register a child of this cookie jar to support inheritance
12,522
public function offsetGet ( $ key ) { if ( isset ( $ this -> jar [ $ key ] ) and ! $ this -> jar [ $ key ] -> isDeleted ( ) ) { return $ this -> jar [ $ key ] ; } elseif ( $ this -> has ( $ key ) ) { return $ this -> parent [ $ key ] ; } else { throw new \ OutOfBoundsException ( 'Access to undefined cookie: ' . $ key )...
Allow fetching values as an array
12,523
public function offsetUnset ( $ key ) { if ( isset ( $ this -> jar [ $ key ] ) ) { $ this -> jar [ $ key ] -> delete ( ) ; } elseif ( $ this -> parentEnabled ) { $ this -> parent -> delete ( $ key ) ; } }
Allow unsetting values like an array
12,524
public function get ( $ property ) { switch ( $ property ) { case 'code' : return $ this -> _code ; break ; case 'data' : return $ this -> _data ; break ; case 'headers' : return $ this -> _headers ; break ; default : if ( $ this -> _headers != null && array_key_exists ( $ property , $ this -> _headers ) ) { return $ t...
Return the specified property
12,525
public function set ( $ property , $ value ) { switch ( $ property ) { case 'code' : $ this -> _code = $ value ; break ; case 'data' : $ this -> _data = $ value ; break ; case 'headers' : $ this -> _headers = $ value ; break ; default : throw new HarvestException ( sprintf ( 'Unknown property %s::%s' , get_class ( $ th...
sets the specified property
12,526
public function quoteArray ( array $ array ) : array { if ( empty ( $ array ) ) { return [ ] ; } foreach ( $ array as $ key => $ value ) { if ( $ value instanceof RawExp ) { $ array [ $ key ] = $ value -> getValue ( ) ; continue ; } $ array [ $ key ] = $ this -> quoteValue ( $ value ) ; } return $ array ; }
Quote array values .
12,527
public function quoteValue ( $ value ) : string { if ( $ value === null ) { return 'NULL' ; } $ result = $ this -> pdo -> quote ( $ value ) ; if ( $ result === false ) { throw new RuntimeException ( 'The database driver does not support quoting in this way.' ) ; } return $ result ; }
Quotes a value for use in a query .
12,528
public function quoteNames ( array $ identifiers ) : array { foreach ( $ identifiers as $ key => $ identifier ) { if ( $ identifier instanceof RawExp ) { $ identifiers [ $ key ] = $ identifier -> getValue ( ) ; continue ; } $ identifiers [ $ key ] = $ this -> quoteName ( $ identifier ) ; } return $ identifiers ; }
Quote array of names .
12,529
protected function quoteNameWithSeparator ( string $ spec , string $ sep , int $ pos ) : string { $ len = strlen ( $ sep ) ; $ part1 = $ this -> quoteName ( substr ( $ spec , 0 , $ pos ) ) ; $ part2 = $ this -> quoteIdentifier ( substr ( $ spec , $ pos + $ len ) ) ; return "{$part1}{$sep}{$part2}" ; }
Quotes an identifier that has a separator .
12,530
public function quoteSetValues ( array $ row ) : string { $ values = [ ] ; foreach ( $ row as $ key => $ value ) { if ( $ value instanceof RawExp ) { $ values [ ] = $ this -> quoteName ( $ key ) . '=' . $ value -> getValue ( ) ; continue ; } $ values [ ] = $ this -> quoteName ( $ key ) . '=' . $ this -> quoteValue ( $ ...
Quote Set values .
12,531
public function quoteBulkValues ( array $ row ) : string { $ values = [ ] ; foreach ( $ row as $ key => $ value ) { $ values [ ] = $ this -> quoteValue ( $ value ) ; } return implode ( ',' , $ values ) ; }
Quote bulk values .
12,532
public function quoteFields ( array $ row ) : string { $ fields = [ ] ; foreach ( array_keys ( $ row ) as $ field ) { $ fields [ ] = $ this -> quoteName ( $ field ) ; } return implode ( ', ' , $ fields ) ; }
Quote fields values .
12,533
private static function deriveResourceFilter ( $ results ) { $ default = function ( ) { return [ ] ; } ; if ( ! is_array ( $ results ) || ! isset ( $ results [ 0 ] [ 'resourceURI' ] ) ) { return $ default ; } $ pattern = '^' . preg_quote ( Client :: BASE_URL ) . '(?P<resource>[a-z]*)/\d+$' ; $ matches = [ ] ; preg_matc...
Helper method to derive the filter to use for the given resource array
12,534
public function ciRun ( $ environment , $ args = '' ) { $ runner = new Runner ( $ environment ) ; $ runner -> buildImage ( ) ; $ runner -> runServices ( ) ; $ res = $ runner -> getContainerRunner ( ) -> exec ( $ runner -> getRunCommand ( ) ) -> args ( $ args ) -> run ( ) ; $ runner -> stopServices ( ) ; ! $ res -> getE...
Executes build for specified RoboCI environment
12,535
public function ciShell ( $ environment , $ args = '' ) { $ runner = new Runner ( $ environment ) ; $ res = $ runner -> buildImage ( ) ; if ( ! $ res -> wasSuccessful ( ) ) return 1 ; $ runner -> runServices ( ) ; $ links = array_keys ( $ runner -> getServices ( ) ) ; $ links = implode ( ' ' , array_map ( function ( $ ...
Runs interactive bash shell in RoboCI environment
12,536
public function queryValues ( string $ sql , string $ key ) : array { $ result = [ ] ; $ statement = $ this -> query ( $ sql ) ; while ( $ row = $ statement -> fetch ( PDO :: FETCH_ASSOC ) ) { $ result [ ] = $ row [ $ key ] ; } return $ result ; }
Retrieving a list of column values .
12,537
public function queryValue ( string $ sql , string $ column , $ default = null ) { $ result = $ default ; if ( $ row = $ this -> query ( $ sql ) -> fetch ( PDO :: FETCH_ASSOC ) ) { $ result = $ row [ $ column ] ; } return $ result ; }
Retrieve only the given column of the first result row .
12,538
public function getActiveClients ( ) { $ result = $ this -> getClients ( ) ; if ( $ result -> isSuccess ( ) ) { $ clients = array ( ) ; foreach ( $ result -> data as $ client ) { if ( $ client -> active == "true" ) { $ clients [ $ client -> id ] = $ client ; } } $ result -> data = $ clients ; } return $ result ; }
get all active clients
12,539
public function getInactiveProjects ( ) { $ result = $ this -> getProjects ( ) ; if ( $ result -> isSuccess ( ) ) { $ projects = array ( ) ; foreach ( $ result -> data as $ project ) { if ( $ project -> active == "false" ) { $ projects [ $ project -> id ] = $ project ; } } $ result -> data = $ projects ; } return $ res...
get all inactive projects
12,540
public function getClientActiveProjects ( $ client_id ) { $ result = $ this -> getClientProjects ( $ client_id ) ; if ( $ result -> isSuccess ( ) ) { $ projects = array ( ) ; foreach ( $ result -> data as $ project ) { if ( $ project -> active == "true" ) { $ projects [ $ project -> id ] = $ project ; } } $ result -> d...
get all active projects
12,541
public function getActiveUsers ( ) { $ result = $ this -> getUsers ( ) ; if ( $ result -> isSuccess ( ) ) { $ data = array ( ) ; foreach ( $ result -> data as $ obj ) { if ( $ obj -> get ( "is-active" ) == "true" ) { $ data [ $ obj -> id ] = $ obj ; } } $ result -> data = $ data ; } return $ result ; }
get all active users
12,542
public function getActiveTimers ( ) { $ result = $ this -> getActiveUsers ( ) ; if ( $ result -> isSuccess ( ) ) { $ data = array ( ) ; foreach ( $ result -> data as $ user ) { $ subResult = $ this -> getUserEntries ( $ user -> id , Range :: today ( $ this -> _timeZone ) ) ; if ( $ subResult -> isSuccess ( ) ) { foreac...
get all active time entries
12,543
public function getUsersActiveTimer ( $ user_id ) { $ result = $ this -> getUserEntries ( $ user_id , Range :: today ( $ this -> _timeZone ) ) ; if ( $ result -> isSuccess ( ) ) { $ data = null ; foreach ( $ result -> data as $ entry ) { if ( $ entry -> timer_started_at != null || $ entry -> timer_started_at != "" ) { ...
get a user s active time entry
12,544
public function getProjectTasks ( $ project_id ) { $ result = $ this -> getProjectTaskAssignments ( $ project_id ) ; if ( $ result -> isSuccess ( ) ) { $ tasks = array ( ) ; foreach ( $ result -> data as $ taskAssignment ) { $ taskResult = $ this -> getTask ( $ taskAssignment -> task_id ) ; if ( $ taskResult -> isSucce...
get all tasks assigned to a project
12,545
public static function delete ( & $ array , $ key ) { if ( is_null ( $ key ) ) { return false ; } if ( is_array ( $ key ) ) { $ return = array ( ) ; foreach ( $ key as $ k ) { $ return [ $ k ] = static :: delete ( $ array , $ k ) ; } return $ return ; } $ key_parts = explode ( '.' , $ key ) ; if ( ! is_array ( $ array ...
Unsets dot - notated key from an array
12,546
public static function assocToKeyval ( $ assoc , $ key_field , $ val_field ) { if ( ! is_array ( $ assoc ) and ! $ assoc instanceof \ Iterator ) { throw new \ InvalidArgumentException ( 'The first parameter must be an array.' ) ; } $ output = array ( ) ; foreach ( $ assoc as $ row ) { if ( isset ( $ row [ $ key_field ]...
Converts a multi - dimensional associative array into an array of key = > values with the provided field names
12,547
public static function toAssoc ( $ arr ) { if ( ( $ count = count ( $ arr ) ) % 2 > 0 ) { throw new \ BadMethodCallException ( 'Number of values in to_assoc must be even.' ) ; } $ keys = $ vals = array ( ) ; for ( $ i = 0 ; $ i < $ count - 1 ; $ i += 2 ) { $ keys [ ] = array_shift ( $ arr ) ; $ vals [ ] = array_shift (...
Converts the given 1 dimensional non - associative array to an associative array .
12,548
public static function prepend ( & $ arr , $ key , $ value = null ) { $ arr = ( is_array ( $ key ) ? $ key : array ( $ key => $ value ) ) + $ arr ; }
Prepends a value with an asociative key to an array . Will overwrite if the value exists .
12,549
public static function unique ( $ arr ) { return array_filter ( $ arr , function ( $ item ) { static $ vars = array ( ) ; if ( in_array ( $ item , $ vars , true ) ) { return false ; } else { $ vars [ ] = $ item ; return true ; } } ) ; }
Returns only unique values in an array . It does not sort . First value is used .
12,550
public static function nextByKey ( $ array , $ key , $ getValue = false , $ strict = false ) { if ( ! is_array ( $ array ) and ! $ array instanceof \ ArrayAccess ) { throw new \ InvalidArgumentException ( 'First parameter must be an array or ArrayAccess object.' ) ; } $ keys = array_keys ( $ array ) ; if ( ( $ index = ...
Get the next value or key from an array using the current array key
12,551
public static function subset ( array $ array , array $ keys , $ default = null ) { $ result = array ( ) ; foreach ( $ keys as $ key ) { static :: set ( $ result , $ key , static :: get ( $ array , $ key , $ default ) ) ; } return $ result ; }
Return the subset of the array defined by the supplied keys .
12,552
public function instance ( ) { $ this -> paths ( ) ; $ this -> environment ( $ this -> constants [ 'ENVIRONMENT' ] ) ; $ this -> constants ( ) ; $ this -> common ( ) ; $ this -> config ( ) ; require 'helpers.php' ; $ instance = \ CI_Controller :: get_instance ( ) ; empty ( $ instance ) && $ instance = new \ CI_Controll...
Returns the Codeigniter singleton .
12,553
public function set ( $ key , $ value ) { $ this -> constants [ $ key ] = $ value ; $ same = $ key === 'APPPATH' ; $ path = $ this -> constants [ $ key ] . '/views/' ; $ same && $ this -> constants [ 'VIEWPATH' ] = $ path ; return $ this ; }
Sets the constant with a value .
12,554
protected function basepath ( ) { $ directory = new \ RecursiveDirectoryIterator ( getcwd ( ) ) ; $ iterator = new \ RecursiveIteratorIterator ( $ directory ) ; foreach ( $ iterator as $ item ) { $ core = 'core' . DIRECTORY_SEPARATOR . 'CodeIgniter.php' ; $ exists = strpos ( $ item -> getPathname ( ) , $ core ) !== fal...
Sets the base path .
12,555
protected function charset ( ) { ini_set ( 'default_charset' , $ charset = strtoupper ( config_item ( 'charset' ) ) ) ; defined ( 'MB_ENABLED' ) || define ( 'MB_ENABLED' , extension_loaded ( 'mbstring' ) ) ; $ encoding = 'mbstring.internal_encoding' ; ! is_php ( '5.6' ) && ! ini_get ( $ encoding ) && ini_set ( $ encodi...
Sets up important charset - related stuff .
12,556
protected function config ( ) { $ this -> globals [ 'CFG' ] = & load_class ( 'Config' , 'core' ) ; $ this -> globals [ 'UNI' ] = & load_class ( 'Utf8' , 'core' ) ; $ this -> globals [ 'SEC' ] = & load_class ( 'Security' , 'core' ) ; $ this -> core ( ) ; }
Sets global configurations .
12,557
protected function constants ( ) { $ config = APPPATH . 'config/' ; $ constants = $ config . ENVIRONMENT . '/constants.php' ; $ filename = $ config . 'constants.php' ; file_exists ( $ constants ) && $ filename = $ constants ; defined ( 'FILE_READ_MODE' ) || require $ filename ; }
Loads the framework constants .
12,558
protected function environment ( $ value = 'development' ) { isset ( $ this -> server [ 'CI_ENV' ] ) && $ value = $ this -> server [ 'CI_ENV' ] ; defined ( 'ENVIRONMENT' ) || define ( 'ENVIRONMENT' , $ value ) ; }
Sets up the current environment .
12,559
protected function paths ( ) { $ paths = array ( 'APPPATH' => $ this -> constants [ 'APPPATH' ] ) ; $ paths [ 'VENDOR' ] = $ this -> constants [ 'VENDOR' ] ; $ paths [ 'VIEWPATH' ] = $ this -> constants [ 'VIEWPATH' ] ; foreach ( ( array ) $ paths as $ key => $ value ) { $ defined = defined ( $ key ) ; $ defined || def...
Sets up the APPPATH VENDOR and BASEPATH constants .
12,560
public function download ( $ dest , $ callback = null ) { if ( $ this -> isFolder ( ) ) { return $ this -> downloadFolder ( $ dest , $ callback ) ; } return $ this -> downloadFile ( $ dest , $ callback ) ; }
Download contents of Node to local save path . If only the local directory is given the file will be saved as its remote name .
12,561
protected function downloadFile ( $ dest , $ callback = null ) { $ retval = [ 'success' => false , 'data' => [ ] , ] ; if ( is_resource ( $ dest ) ) { $ handle = $ dest ; $ metadata = stream_get_meta_data ( $ handle ) ; $ dest = $ metadata [ "uri" ] ; } else { $ dest = rtrim ( $ dest , '/' ) ; if ( file_exists ( $ dest...
Save a FILE node to the specified local destination .
12,562
protected function downloadFolder ( $ dest , $ callback = null ) { $ retval = [ 'success' => false , 'data' => [ ] , ] ; if ( ! is_string ( $ dest ) ) { throw new \ Exception ( "Must pass in local path to download directory to." ) ; } $ nodes = $ this -> getChildren ( ) ; $ dest = rtrim ( $ dest ) . "/{$this['name']}" ...
Recursively download all children of a FOLDER node to the specified local destination .
12,563
public function getMetadata ( $ tempLink = false ) { $ retval = [ 'success' => false , 'data' => [ ] , ] ; $ query = [ ] ; if ( $ tempLink ) { $ query [ 'tempLink' ] = true ; } $ response = self :: $ httpClient -> get ( self :: $ account -> getMetadataUrl ( ) . "nodes/{$this['id']}" , [ 'headers' => [ 'Authorization' =...
Retrieve the node s metadata directly from the API .
12,564
public function getPath ( ) { $ node = $ this ; $ path = [ ] ; while ( true ) { $ path [ ] = $ node [ "name" ] ; if ( $ node -> isRoot ( ) ) { break ; } $ node = self :: loadById ( $ node [ "parents" ] [ 0 ] ) ; if ( is_null ( $ node ) ) { throw new \ Exception ( "No parent node found with ID {$node['parents'][0]}." ) ...
Build and return the remote directory path of the given Node .
12,565
public static function init ( Account $ account , Cache $ cacheStore ) { if ( self :: $ initialized === true ) { throw new \ Exception ( "`Node` class has already been initialized." ) ; } self :: $ account = $ account ; self :: $ cacheStore = $ cacheStore ; self :: $ httpClient = new Client ( ) ; self :: $ initialized ...
Set the local storage cache .
12,566
public static function load ( $ param ) { if ( ! ( $ node = self :: loadById ( $ param ) ) ) { $ node = self :: loadByPath ( $ param ) ; } return $ node ; }
Load a Node given an ID or remote path .
12,567
public static function loadByPath ( $ path ) { $ path = trim ( $ path , '/' ) ; if ( ! $ path ) { return self :: loadRoot ( ) ; } $ info = pathinfo ( $ path ) ; $ nodes = self :: loadByName ( $ info [ 'basename' ] ) ; if ( empty ( $ nodes ) ) { return null ; } foreach ( $ nodes as $ node ) { if ( $ node -> getPath ( ) ...
Find and return Node that matches the given remote path .
12,568
public static function loadRoot ( ) { $ results = self :: loadByName ( 'Cloud Drive' ) ; if ( empty ( $ results ) ) { throw new \ Exception ( "No node by name 'Cloud Drive' found in the database." ) ; } foreach ( $ results as $ result ) { if ( $ result -> isRoot ( ) ) { return $ result ; } } throw new \ Exception ( "Un...
Return the root Node .
12,569
public function move ( Node $ newFolder ) { if ( ! $ newFolder -> isFolder ( ) ) { throw new \ Exception ( "New destination node is not a folder." ) ; } if ( ! $ this -> isFile ( ) && ! $ this -> isFolder ( ) ) { throw new \ Exception ( "Moving a node can only be performed on FILE and FOLDER kinds." ) ; } $ retval = [ ...
Move a FILE or FOLDER Node to a new remote location .
12,570
public function overwrite ( $ localPath ) { $ retval = [ 'success' => false , 'data' => [ ] , ] ; $ response = self :: $ httpClient -> put ( self :: $ account -> getContentUrl ( ) . "nodes/{$this['id']}/content" , [ 'headers' => [ 'Authorization' => 'Bearer ' . self :: $ account -> getToken ( ) [ 'access_token' ] , ] ,...
Replace file contents of the Node with the file located at the given local path .
12,571
public function rename ( $ name ) { $ retval = [ 'success' => false , 'data' => [ ] , ] ; $ response = self :: $ httpClient -> patch ( self :: $ account -> getMetadataUrl ( ) . "nodes/{$this['id']}" , [ 'headers' => [ 'Authorization' => 'Bearer ' . self :: $ account -> getToken ( ) [ 'access_token' ] , ] , 'json' => [ ...
Modify the name of a remote Node .
12,572
public function restore ( ) { $ retval = [ 'success' => false , 'data' => [ ] , ] ; if ( $ this [ 'status' ] === 'AVAILABLE' ) { $ retval [ 'data' ] [ 'message' ] = 'Node is already available.' ; return $ retval ; } $ response = self :: $ httpClient -> post ( self :: $ account -> getMetadataUrl ( ) . "trash/{$this['id'...
Restore the Node from the trash .
12,573
public function next ( ) { $ this -> key ++ ; $ this -> current = $ this -> current -> add ( $ this -> interval ) ; }
Moves the current position to the next date .
12,574
private static function cast ( Date $ date = null ) { if ( ! is_null ( $ date ) ) { $ date = new DateTime ( $ date ) ; } return $ date ; }
Casts to DateTime .
12,575
public function formRecaptcha ( $ name , $ value = null , $ attribs = null , $ options = null , $ listsep = '' ) { if ( ! isset ( $ attribs [ 'siteKey' ] ) || ! isset ( $ attribs [ 'secretKey' ] ) ) { throw new \ Zend_Exception ( 'Site key is not set in the view helper' ) ; } $ customClasses = '' ; if ( isset ( $ attri...
For google recaptcha div to render properly
12,576
protected function _extract ( $ item , $ keys = array ( 'value' ) ) { if ( is_array ( $ item ) ) { if ( isset ( $ item [ 0 ] ) ) { return $ this -> _extract ( $ item [ 0 ] , $ keys ) ; } else { foreach ( $ keys as $ key ) { if ( ! empty ( $ item [ $ key ] ) ) { return trim ( $ item [ $ key ] ) ; } else if ( isset ( $ i...
Extracts a certain value from a node .
12,577
protected function _truncate ( $ feed , $ count = null ) { if ( ! $ feed ) { return $ feed ; } if ( $ count === null ) { $ count = 20 ; } if ( $ count && count ( $ feed ) > $ count ) { $ feed = array_slice ( $ feed , 0 , $ count ) ; } return array_values ( $ feed ) ; }
Truncates the feed to a certain length .
12,578
public function ciTravisBuild ( $ opts = [ 'name' => null , 'recipes' => false , 'image' => false ] ) { if ( ! $ opts [ 'image' ] ) $ opts [ 'image' ] = Config :: $ baseImage ; return ( new Builder ) -> execute ( $ opts ) ; }
Provisions new container using Chef cookbooks from Travis CI Takes very looooooooooong time better to use created image
12,579
public function get ( $ property ) { $ value = null ; if ( $ this -> _convert ) { $ property = str_replace ( "_" , "-" , $ property ) ; } else { $ property = str_replace ( "-" , "_" , $ property ) ; } if ( array_key_exists ( $ property , $ this -> _values ) ) { return $ this -> _values [ $ property ] ; } else { return ...
get specified property
12,580
public function parseXml ( $ node ) { foreach ( $ node -> childNodes as $ item ) { if ( $ item -> nodeName != "#text" ) { $ this -> set ( $ item -> nodeName , $ item -> nodeValue ) ; } } }
magic method used for method overloading
12,581
protected function getRightFieldValue ( $ rightField , $ comparison ) : array { if ( $ comparison == 'in' || $ comparison == 'not in' ) { $ rightField = '(' . implode ( ', ' , $ this -> quoter -> quoteArray ( ( array ) $ rightField ) ) . ')' ; } elseif ( $ comparison == 'greatest' || $ comparison == 'least' || $ compar...
Comparison Functions and Operators .
12,582
public function where ( $ conditions ) : self { if ( $ conditions [ 0 ] instanceof Closure ) { $ this -> addClauseCondClosure ( 'where' , 'AND' , $ conditions [ 0 ] ) ; return $ this ; } $ this -> where [ ] = [ 'and' , $ conditions ] ; return $ this ; }
Where AND condition .
12,583
protected function addClauseCondClosure ( $ clause , $ andor , $ closure ) { $ set = $ this -> $ clause ; $ this -> $ clause = [ ] ; $ closure ( $ this -> query ) ; if ( ! $ this -> $ clause ) { $ this -> $ clause = $ set ; return ; } if ( $ set ) { $ set [ ] = new RawExp ( strtoupper ( $ andor ) . ' (' ) ; } else { $ ...
Adds to a clause through a closure enclosing within parentheses .
12,584
public function get ( $ delimit = true ) { if ( $ this -> openDelimiters !== 0 ) { throw new \ LogicException ( 'A delimiter has not been closed!' ) ; } $ expression = $ this -> expression ; if ( $ delimit ) { $ expression = '/' . $ expression . '/' . $ this -> flags ; } return $ expression ; }
Gets the built expression
12,585
public function get ( $ item , array $ replace = array ( ) ) { $ this -> load ( ) ; if ( ! isset ( $ this -> loaded [ $ this -> locale ] [ $ item ] ) ) { return $ item ; } $ line = $ this -> loaded [ $ this -> locale ] [ $ item ] ; return $ this -> makeReplacements ( $ line , $ replace ) ; }
Returns a translated item .
12,586
public function choice ( $ item , $ number , array $ replace = array ( ) ) { $ lines = $ this -> get ( $ item , $ replace ) ; $ replace [ 'count' ] = $ number ; return $ this -> makeReplacements ( $ this -> selector -> choose ( $ lines , $ number , $ this -> locale ) , $ replace ) ; }
Returns a translated item with a proper form for pluralization .
12,587
private function load ( ) { if ( $ this -> isLoaded ( ) ) { return ; } $ path = sprintf ( '%s/../../lang/%s.php' , __DIR__ , $ this -> locale ) ; if ( file_exists ( $ path ) ) { $ this -> loaded [ $ this -> locale ] = require $ path ; } }
Loads dictionary .
12,588
private function makeReplacements ( $ line , array $ replace ) { foreach ( $ replace as $ key => $ value ) { $ line = str_replace ( ':' . $ key , $ value , $ line ) ; } return $ line ; }
Replaces elements in a line .
12,589
public function offsetExists ( $ offset ) { foreach ( $ this as $ key => $ value ) { if ( $ key == $ offset ) { return true ; } } return false ; }
Check if a given object exists
12,590
protected function loadPlugin ( $ plugin ) { $ pluginName = get_class ( $ plugin ) ; $ apiVersion = self :: API_VERSION_0_9 ; if ( $ plugin instanceof PicoPluginInterface ) { if ( defined ( $ pluginName . '::API_VERSION' ) ) { $ apiVersion = $ pluginName :: API_VERSION ; } else { $ apiVersion = self :: API_VERSION_1_0 ...
Adds a plugin to PicoDeprecated s plugin index to trigger deprecated events by API level
12,591
public function onConfigLoaded ( array & $ config ) { $ this -> defineConstants ( ) ; $ this -> loadScriptedConfig ( $ config ) ; $ this -> loadRootDirConfig ( $ config ) ; if ( ! isset ( $ GLOBALS [ 'config' ] ) ) { $ GLOBALS [ 'config' ] = & $ config ; } }
Re - introduces various config - related characteristics
12,592
protected function defineConstants ( ) { if ( ! defined ( 'ROOT_DIR' ) ) { define ( 'ROOT_DIR' , $ this -> getRootDir ( ) ) ; } if ( ! defined ( 'CONFIG_DIR' ) ) { define ( 'CONFIG_DIR' , $ this -> getConfigDir ( ) ) ; } if ( ! defined ( 'LIB_DIR' ) ) { $ picoReflector = new ReflectionClass ( 'Pico' ) ; define ( 'LIB_D...
Defines various config - related constants
12,593
protected function loadRootDirConfig ( array & $ realConfig ) { if ( file_exists ( $ this -> getRootDir ( ) . 'config.php' ) ) { $ config = null ; $ includeClosure = function ( $ configFile ) use ( & $ config ) { require ( $ configFile ) ; } ; if ( PHP_VERSION_ID >= 50400 ) { $ includeClosure = $ includeClosure -> bind...
Reads a config . php in Pico s root dir
12,594
protected function lowerFileMeta ( array & $ meta ) { $ metaHeaders = $ this -> getMetaHeaders ( ) ; $ unregisteredMeta = array ( ) ; foreach ( $ meta as $ key => $ value ) { if ( ! in_array ( $ key , $ metaHeaders ) ) { $ unregisteredMeta [ $ key ] = & $ meta [ $ key ] ; } } if ( $ unregisteredMeta ) { $ metaHeadersLo...
Lowers a page s meta headers as with Pico 1 . 0 and older
12,595
public function triggersApiEvents ( $ apiVersion ) { $ apiVersions = func_get_args ( ) ; foreach ( $ apiVersions as $ apiVersion ) { if ( isset ( $ this -> plugins [ $ apiVersion ] ) ) { return true ; } } return false ; }
Returns whether events of a particular API level are triggered or not
12,596
public function triggerEvent ( $ apiVersion , $ eventName , array $ params = array ( ) ) { if ( ! isset ( $ this -> plugins [ $ apiVersion ] ) ) { return ; } if ( $ apiVersion === self :: API_VERSION_0_9 ) { $ plugins = $ this -> plugins [ self :: API_VERSION_0_9 ] ; if ( isset ( $ this -> plugins [ self :: API_VERSION...
Triggers deprecated events on plugins of different API versions
12,597
public function validateUrl ( ElementInterface $ element ) { $ value = $ element -> getFieldValue ( $ this -> handle ) ; $ matches = false ; foreach ( $ this -> urlTypes as $ type ) { switch ( $ type ) { case 'relative' : $ matches = $ matches | preg_match ( '/^\/\S*$/iu' , $ value ) ; break ; case 'absolute' : $ match...
Ensures the URL provided matches the allowed URL types .
12,598
protected function consumeTable ( $ lines , $ current ) { $ pattern = <<< REGEXP/(?<=\|)( ([^\|]*?{{{.*?}}}[^\|]*?)+| ([^\|]*~\|[^\|]*?)+| [^\|]*)(?=\|)/xREGEXP ; $ block = [ 'table' , 'rows' => [ ] , ] ; for ( $ i = $ current , $ count = count ( $ lines ) ; $ i < $ count ; $ i ++ ) { $ line = trim ( $ lines [...
Consume lines for a table
12,599
protected function renderTable ( $ block ) { $ content = "" ; $ first = true ; foreach ( $ block [ 'rows' ] as $ row ) { if ( $ first ) { if ( $ row [ 'header' ] ) { $ content .= "<thead>\n" ; } else { $ content .= "<tbody>\n" ; } } $ content .= "<tr>\n" ; foreach ( $ row [ 'cells' ] as $ cell ) { $ tag = $ cell [ 'tag...
render a table block