idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
43,000
public function getTracks ( $ methodVars ) { if ( ! empty ( $ methodVars [ 'user' ] ) ) { $ vars = array ( 'method' => 'library.gettracks' , 'api_key' => $ this -> auth -> apiKey ) ; $ vars = array_merge ( $ vars , $ methodVars ) ; if ( $ call = $ this -> apiGetCall ( $ vars ) ) { $ tracks [ 'page' ] = ( string ) $ cal...
A paginated list of all the tracks in a user s library with play counts and tag counts
43,001
protected function calculateDigest ( $ xml ) { $ xml = $ this -> canonicalize ( $ xml ) ; $ utf8 = utf8_encode ( $ xml . $ this -> options [ 'shared_secret' ] ) ; return base64_encode ( sha1 ( $ utf8 , true ) ) ; }
Calculate digest for message .
43,002
protected function canonicalize ( $ xml ) { $ xml = str_replace ( '<?xml version="1.0" encoding="UTF-8"?>' , null , $ xml ) ; $ replacement = 'xmlns="http://www.modirum.com/schemas" ' ; $ start = 0 ; $ length = 9 ; $ xml = substr ( $ xml , $ start , $ length ) . substr_replace ( $ xml , $ replacement , $ start , $ leng...
Canonicalize message element according to specs .
43,003
public static function gateway ( $ name = null , $ options = array ( ) ) { $ gateway = "\\AktiveMerchant\\Billing\\Gateways\\" . Inflect :: camelize ( $ name ) ; if ( class_exists ( $ gateway ) ) { return new $ gateway ( $ options ) ; } throw new Exception ( "Unable to load class: {$gateway}." ) ; }
Factory method for gateways .
43,004
public function getTopArtists ( $ methodVars ) { $ vars = array ( 'method' => 'chart.gettopartists' , 'api_key' => $ this -> auth -> apiKey ) ; $ vars = array_merge ( $ vars , $ methodVars ) ; if ( $ call = $ this -> apiGetCall ( $ vars ) ) { $ i = 0 ; foreach ( $ call -> artists -> artist as $ artist ) { $ topArtists ...
Get the top artists chart
43,005
public function getTopTags ( $ methodVars ) { $ vars = array ( 'method' => 'chart.gettoptags' , 'api_key' => $ this -> auth -> apiKey ) ; $ vars = array_merge ( $ vars , $ methodVars ) ; if ( $ call = $ this -> apiGetCall ( $ vars ) ) { $ i = 0 ; foreach ( $ call -> tags -> tag as $ tags ) { $ topTags [ $ i ] [ 'name' ...
Get the top tags chart
43,006
public function getTopTracks ( $ methodVars ) { $ vars = array ( 'method' => 'chart.gettoptracks' , 'api_key' => $ this -> auth -> apiKey ) ; $ vars = array_merge ( $ vars , $ methodVars ) ; if ( $ call = $ this -> apiGetCall ( $ vars ) ) { $ i = 0 ; foreach ( $ call -> tracks -> track as $ track ) { $ topTracks [ $ i ...
Get the top tracks chart
43,007
public function getSimilar ( $ methodVars ) { if ( ! empty ( $ methodVars [ 'artist' ] ) && ! empty ( $ methodVars [ 'track' ] ) ) { $ vars = array ( 'method' => 'track.getsimilar' , 'api_key' => $ this -> auth -> apiKey ) ; $ vars = array_merge ( $ vars , $ methodVars ) ; if ( $ call = $ this -> apiGetCall ( $ vars ) ...
Get the similar tracks for this track on Last . fm based on listening data
43,008
public function getTopTags ( $ methodVars ) { if ( ! empty ( $ methodVars [ 'artist' ] ) && ! empty ( $ methodVars [ 'track' ] ) ) { $ vars = array ( 'method' => 'track.gettoptags' , 'api_key' => $ this -> auth -> apiKey ) ; $ vars = array_merge ( $ vars , $ methodVars ) ; if ( $ call = $ this -> apiGetCall ( $ vars ) ...
Get the top tags for this track on Last . fm ordered by tag count
43,009
public function url_stat ( $ path , $ flags = 0 ) { $ now = time ( ) ; $ refPath = StringController :: getRef ( str_replace ( 'string://' , '' , $ path ) ) ; $ string = & $ refPath ; $ stat = array ( 'dev' => 0 , 'ino' => 0 , 'mode' => 0 , 'nlink' => 1 , 'uid' => 0 , 'gid' => 0 , 'rdev' => 0 , 'size' => \ strlen ( $ st...
Method to retrieve information about a file .
43,010
public function stream_read ( $ count ) { $ result = substr ( $ this -> currentString , $ this -> pos , $ count ) ; $ this -> pos += $ count ; return $ result ; }
Method to read a given number of bytes starting at the current position and moving to the end of the string defined by the current position plus the given number .
43,011
public function setOptions ( array $ options ) { if ( isset ( $ options [ 'type' ] ) ) { $ this -> type = $ options [ 'type' ] ; } if ( isset ( $ options [ 'timeout' ] ) ) { $ this -> timeout = $ options [ 'timeout' ] ; } return true ; }
Set client options
43,012
public function connect ( $ host = '127.0.0.1' , $ port = 21 ) { $ errno = null ; $ err = null ; if ( \ is_resource ( $ this -> conn ) ) { return true ; } if ( FTP_NATIVE ) { $ this -> conn = @ ftp_connect ( $ host , $ port , $ this -> timeout ) ; if ( $ this -> conn === false ) { throw new FilesystemException ( sprint...
Method to connect to a FTP server
43,013
public function quit ( ) { if ( FTP_NATIVE ) { @ ftp_close ( $ this -> conn ) ; return true ; } @ fwrite ( $ this -> conn , "QUIT\r\n" ) ; @ fclose ( $ this -> conn ) ; return true ; }
Method to quit and close the connection
43,014
public function reinit ( ) { if ( FTP_NATIVE ) { if ( @ ftp_site ( $ this -> conn , 'REIN' ) === false ) { throw new FilesystemException ( __METHOD__ . 'Bad response.' ) ; } return true ; } if ( ! $ this -> _putCmd ( 'REIN' , 220 ) ) { throw new FilesystemException ( sprintf ( '%1$s: Bad response. Server response: %2$...
Method to reinitialise the server ie . need to login again
43,015
public function chmod ( $ path , $ mode ) { if ( $ path == '' ) { $ path = '.' ; } if ( \ is_int ( $ mode ) ) { $ mode = decoct ( $ mode ) ; } if ( FTP_NATIVE ) { if ( @ ftp_site ( $ this -> conn , 'CHMOD ' . $ mode . ' ' . $ path ) === false ) { if ( ! \ defined ( 'PHP_WINDOWS_VERSION_MAJOR' ) ) { throw new Filesystem...
Method to change mode for a path on the FTP server
43,016
public function listNames ( $ path = null ) { $ data = null ; if ( FTP_NATIVE ) { if ( @ ftp_pasv ( $ this -> conn , true ) === false ) { throw new FilesystemException ( __METHOD__ . ': Unable to use passive mode.' ) ; } if ( ( $ list = @ ftp_nlist ( $ this -> conn , $ path ) ) === false ) { if ( $ this -> listDetails ...
Method to list the filenames of the contents of a directory on the FTP server
43,017
protected function _findMode ( $ fileName ) { if ( $ this -> type == FTP_AUTOASCII ) { $ dot = strrpos ( $ fileName , '.' ) + 1 ; $ ext = substr ( $ fileName , $ dot ) ; if ( \ in_array ( $ ext , $ this -> autoAscii ) ) { $ mode = FTP_ASCII ; } else { $ mode = FTP_BINARY ; } } elseif ( $ this -> type == FTP_ASCII ) { $...
Method to find out the correct transfer mode for a specific file
43,018
public function void ( $ authorization , $ options = array ( ) ) { $ this -> post = array ( ) ; $ params = array ( 'METHOD' => 'DoVoid' , 'AUTHORIZATIONID' => $ authorization ) ; if ( isset ( $ options [ 'note' ] ) ) { $ params [ 'NOTE' ] = $ options [ 'note' ] ; } if ( isset ( $ options [ 'message' ] ) ) { $ params [ ...
Void an authorization .
43,019
public function getTags ( $ methodVars ) { if ( $ this -> getFullAuth ( ) === true ) { if ( ! empty ( $ methodVars [ 'album' ] ) && ! empty ( $ methodVars [ 'artist' ] ) ) { $ vars = array ( 'method' => 'album.gettags' , 'api_key' => $ this -> getAuth ( ) -> apiKey , 'sk' => $ this -> getAuth ( ) -> sessionKey ) ; $ va...
Get the tags applied by an individual user to an album on Last . fm
43,020
public function search ( $ methodVars ) { if ( ! empty ( $ methodVars [ 'album' ] ) ) { $ vars = array ( 'method' => 'album.search' , 'api_key' => $ this -> getAuth ( ) -> apiKey ) ; $ vars = array_merge ( $ vars , $ methodVars ) ; $ searchresults = array ( ) ; if ( $ call = $ this -> apiGetCall ( $ vars ) ) { $ callNa...
Search for an album by name . Returns album matches sorted by relevance
43,021
private function addTransactionElement ( $ amount , $ type , $ options ) { if ( $ type == 'PreAuth' || $ type == 'Auth' ) { $ this -> xml .= <<<XML <Transaction> <Type DataType="String">{$type}</Type> <CurrentTotals> <Totals> <Total DataType="Money" Currency="{$this->currency_lookup(self::$default_currency)}">{$amount...
Add Transaction Element
43,022
private function optionsFrom ( $ response ) { $ options = array ( ) ; $ options [ 'authorization' ] = $ response [ 'transaction_id' ] ; $ options [ 'test' ] = empty ( $ response [ 'mode' ] ) || $ response [ 'mode' ] != 'P' ; $ options [ 'fraud_review' ] = in_array ( $ response [ 'return_code' ] , $ this -> FRAUDULENT )...
Options from Response
43,023
public static function makeSafe ( $ file , array $ stripChars = array ( '#^\.#' ) ) { $ regex = array_merge ( array ( '#(\.){2,}#' , '#[^A-Za-z0-9\.\_\- ]#' ) , $ stripChars ) ; $ file = preg_replace ( $ regex , '' , $ file ) ; $ file = rtrim ( $ file , '.' ) ; return $ file ; }
Makes the file name safe to use
43,024
private function detectFormat ( ) { if ( preg_match ( '/^[[:alpha:]]{2}$/' , $ this -> value ) ) { $ this -> format = 'alpha2' ; } elseif ( preg_match ( '/^[[:alpha:]]{3}$/' , $ this -> value ) ) { $ this -> format = 'alpha3' ; } elseif ( preg_match ( '/^[[:digit:]]{3}$/' , $ this -> value ) ) { $ this -> format = 'num...
Detects the format of country name from the given value .
43,025
public function getImages ( $ methodVars ) { $ vars = array ( 'method' => 'artist.getinfo' , 'api_key' => $ this -> auth -> apiKey ) ; $ vars = array_merge ( $ vars , $ methodVars ) ; if ( $ call = $ this -> apiGetCall ( $ vars ) ) { $ info [ 'image' ] [ 'small' ] = isset ( $ call -> artist -> image [ 0 ] ) ? ( string ...
Get all images for an artist on Last . fm .
43,026
public function getShouts ( $ methodVars ) { if ( ! empty ( $ methodVars [ 'artist' ] ) || ! empty ( $ methodVars [ 'mbid' ] ) ) { $ vars = array ( 'method' => 'artist.getshouts' , 'api_key' => $ this -> auth -> apiKey ) ; $ vars = array_merge ( $ vars , $ methodVars ) ; if ( $ call = $ this -> apiGetCall ( $ vars ) ) ...
Get shouts for this artist .
43,027
public function getSimilar ( $ methodVars ) { if ( ! empty ( $ methodVars [ 'artist' ] ) || ! empty ( $ methodVars [ 'mbid' ] ) ) { $ vars = array ( 'method' => 'artist.getsimilar' , 'api_key' => $ this -> auth -> apiKey ) ; $ vars = array_merge ( $ vars , $ methodVars ) ; if ( $ call = $ this -> apiGetCall ( $ vars ) ...
Get all the artists similar to this artist
43,028
public function getTopAlbums ( $ methodVars ) { if ( ! empty ( $ methodVars [ 'artist' ] ) || ! empty ( $ methodVars [ 'mbid' ] ) ) { $ vars = array ( 'method' => 'artist.gettopalbums' , 'api_key' => $ this -> auth -> apiKey ) ; $ vars = array_merge ( $ vars , $ methodVars ) ; if ( $ call = $ this -> apiGetCall ( $ var...
Get the top albums for an artist on Last . fm ordered by popularity
43,029
public function getTopFans ( $ methodVars ) { if ( ! empty ( $ methodVars [ 'artist' ] ) || ! empty ( $ methodVars [ 'mbid' ] ) ) { $ vars = array ( 'method' => 'artist.gettopfans' , 'api_key' => $ this -> auth -> apiKey ) ; $ vars = array_merge ( $ vars , $ methodVars ) ; if ( $ call = $ this -> apiGetCall ( $ vars ) ...
Get the top fans for an artist on Last . fm based on listening data
43,030
public function getTopTracks ( $ methodVars ) { if ( ! empty ( $ methodVars [ 'artist' ] ) || ! empty ( $ methodVars [ 'mbid' ] ) ) { $ vars = array ( 'method' => 'artist.gettoptracks' , 'api_key' => $ this -> auth -> apiKey ) ; $ vars = array_merge ( $ vars , $ methodVars ) ; if ( $ call = $ this -> apiGetCall ( $ var...
Get the top tracks by an artist on Last . fm ordered by popularity
43,031
public function search ( $ methodVars ) { if ( ! empty ( $ methodVars [ 'artist' ] ) ) { $ vars = array ( 'method' => 'artist.search' , 'api_key' => $ this -> auth -> apiKey ) ; $ vars = array_merge ( $ vars , $ methodVars ) ; if ( $ call = $ this -> apiGetCall ( $ vars ) ) { $ callNamespaces = $ call -> getDocNamespac...
Search for an artist by name . Returns artist matches sorted by relevance
43,032
public function _buildContext ( ) { if ( \ count ( $ this -> contextOptions ) ) { $ this -> context = @ stream_context_create ( $ this -> contextOptions ) ; } else { $ this -> context = null ; } }
Stream contexts Builds the context from the array
43,033
public function addContextEntry ( $ wrapper , $ name , $ value ) { $ this -> contextOptions [ $ wrapper ] [ $ name ] = $ value ; $ this -> _buildContext ( ) ; }
Adds a particular options to the context
43,034
public function deleteContextEntry ( $ wrapper , $ name ) { if ( isset ( $ this -> contextOptions [ $ wrapper ] ) ) { if ( isset ( $ this -> contextOptions [ $ wrapper ] [ $ name ] ) ) { unset ( $ this -> contextOptions [ $ wrapper ] [ $ name ] ) ; if ( ! \ count ( $ this -> contextOptions [ $ wrapper ] ) ) { unset ( $...
Deletes a particular setting from a context
43,035
public function writeFile ( $ filename , & $ buffer , $ appendToFile = false ) { $ fileMode = 'w' ; if ( $ appendToFile ) { $ fileMode = 'a' ; } if ( $ this -> open ( $ filename , $ fileMode ) ) { $ result = $ this -> write ( $ buffer ) ; $ this -> chmod ( ) ; $ this -> close ( ) ; return $ result ; } return false ; }
Writes a chunk of data to a file .
43,036
public function purchase ( $ money , $ creditcard , $ options = array ( ) ) { Options :: required ( 'order_id, ip' , $ options ) ; $ this -> post = array ( ) ; $ options = new Options ( $ options ) ; $ this -> addInvoice ( $ options -> order_id , $ money ) ; if ( is_string ( $ creditcard ) ) { Options :: required ( 'cv...
Charge a credit card .
43,037
public function store ( CreditCard $ creditcard , $ options = array ( ) ) { $ this -> post = array ( ) ; $ this -> addCreditcard ( $ creditcard ) ; return $ this -> commit ( 'credit_cards' ) ; }
Stores a reference of a credit card .
43,038
public function recurring ( $ plan , CreditCard $ creditcard , $ options = array ( ) ) { $ this -> post = array ( ) ; Options :: required ( 'first_name, last_name, email, customer_id, start_date, period' , $ options ) ; $ options = new Options ( $ options ) ; if ( null === $ options -> customer_id ) { $ response = $ th...
Creates a recurring billing subscription for a customer .
43,039
public function updatePlan ( $ plan_id , array $ attrs = array ( ) ) { $ this -> post = array ( ) ; $ attrs = new Options ( $ attrs ) ; $ plan_id = urlencode ( trim ( $ plan_id ) ) ; if ( $ attrs -> name ) { $ this -> post [ 'name' ] = $ attrs -> name ; } if ( $ attrs -> description ) { $ this -> post [ 'description' ]...
Update attributes of a plan .
43,040
public function updateCustomer ( $ customer_id , CreditCard $ creditcard = null , $ options = array ( ) ) { $ this -> post = array ( ) ; $ options = new Options ( $ options ) ; $ this -> addCustomerData ( $ options ) ; $ this -> addAddress ( $ options ) ; $ address = $ this -> post [ 'address' ] ; unset ( $ this -> pos...
Updates customer information .
43,041
public function getRootFormCascadeOption ( FormInterface $ form ) { if ( ! $ form -> isRoot ( ) ) { return $ this -> getRootFormCascadeOption ( $ form -> getParent ( ) ) ; } return $ form -> getConfig ( ) -> getOption ( 'cascade_filter' , false ) ; }
Navigates to the Root form to define if cascading should be done .
43,042
public function activate ( ) { $ duration = ( int ) $ this -> params [ 'duration' ] ; $ this -> Maintenance -> setMaintenanceMode ( $ duration ) ; $ this -> out ( 'Maintenance mode activated ...' ) ; }
Activate maintenance mode with an optional timeout setting .
43,043
public function whitelist ( ) { if ( $ this -> params [ 'remove' ] ) { $ this -> Maintenance -> clearWhitelist ( ) ; } $ ips = $ this -> args ; if ( ! empty ( $ ips ) ) { foreach ( $ ips as $ ip ) { if ( ! Validation :: ip ( $ ip ) ) { $ this -> abort ( $ ip . ' is not a valid IP address.' ) ; } } if ( $ this -> params...
Whitelist specific IPs . Each argument is a single IP . Not passing any argument will output the current whitelist .
43,044
public function proxy ( array $ ips = [ ] , array $ headers = [ 'Forwarded' , 'Forwarded-For' , 'X-Forwarded' , 'X-Forwarded-For' , 'X-Cluster-Client-Ip' , 'Client-Ip' , ] ) : self { $ this -> proxyIps = $ ips ; $ this -> proxyHeaders = $ headers ; return $ this ; }
Configure the proxy .
43,045
private function isInProxiedIps ( string $ ip ) : bool { foreach ( $ this -> proxyIps as $ proxyIp ) { if ( $ ip === $ proxyIp || self :: isInCIDR ( $ ip , $ proxyIp ) ) { return true ; } } return false ; }
checks if the given ip address is in the list of proxied ips provided
43,046
private function getRemoteIp ( ) { if ( $ this -> remote ) { $ ip = file_get_contents ( 'http://ipecho.net/plain' ) ; if ( $ ip && self :: isValid ( $ ip ) ) { return $ ip ; } } }
Returns the IP address from remote service .
43,047
private function getForwardedHeaderIp ( string $ header ) { foreach ( array_reverse ( array_map ( 'trim' , explode ( ',' , strtolower ( $ header ) ) ) ) as $ values ) { foreach ( array_reverse ( array_map ( 'trim' , explode ( ';' , $ values ) ) ) as $ directive ) { if ( strpos ( $ directive , 'for=' ) !== 0 ) { continu...
Returns the first valid ip found in the Forwarded or X - Forwarded header .
43,048
public function startup ( ) { parent :: startup ( ) ; if ( ! empty ( $ this -> params [ 'dry-run' ] ) ) { $ this -> out ( '<warning>Dry-run mode enabled!</warning>' , 1 , Shell :: QUIET ) ; } }
Shell startup prints info message about dry run .
43,049
public function emptyFolders ( $ path = null ) { if ( $ path ) { $ path = realpath ( $ path ) ; } if ( ! $ path ) { $ path = ROOT . DS ; } $ this -> out ( 'Clearing empty folders in ' . $ path ) ; $ this -> _clearEmpty ( $ path ) ; }
Clean out empty folders that only contain an empty placeholder file .
43,050
public function beforeMarshal ( Event $ event , ArrayObject $ data , ArrayObject $ options ) { $ field = $ this -> getConfig ( 'field' ) ; $ property = $ this -> getConfig ( 'tagsAssoc.propertyName' ) ; $ options [ 'accessibleFields' ] [ $ property ] = true ; if ( isset ( $ data [ $ field ] ) ) { $ data [ $ property ] ...
Before marshal callback
43,051
protected function _tagExists ( $ tag ) { $ tagsTable = $ this -> _table -> { $ this -> getConfig ( 'tagsAlias' ) } -> getTarget ( ) ; $ result = $ tagsTable -> find ( ) -> where ( [ $ tagsTable -> aliasField ( 'slug' ) => $ tag , ] ) -> select ( [ $ tagsTable -> aliasField ( $ tagsTable -> getPrimaryKey ( ) ) ] ) -> f...
Checks if a tag already exists and returns the id if yes .
43,052
protected function _normalizeTag ( $ tag ) { $ namespace = null ; $ label = $ tag ; $ separator = $ this -> getConfig ( 'separator' ) ; if ( $ separator === null ) { return [ null , $ tag , ] ; } if ( strpos ( $ tag , $ separator ) !== false ) { list ( $ namespace , $ label ) = explode ( $ separator , $ tag ) ; } retur...
Normalizes a tag string by trimming unnecessary whitespace and extracting the tag identifier from a tag in case it exists .
43,053
public function eof ( ) { if ( ! empty ( $ this -> args [ 0 ] ) ) { $ folder = realpath ( $ this -> args [ 0 ] ) ; } else { $ folder = APP ; } $ App = new Folder ( $ folder ) ; $ this -> out ( 'Checking *.php in ' . $ folder ) ; $ files = $ App -> findRecursive ( '.*\.php' ) ; $ this -> out ( 'Found ' . count ( $ files...
Whitespaces at the end of the file If PHP file with trailing ? > that will be removed as per coding standards .
43,054
public static function cleanedUrl ( $ type , $ urlArray ) { $ types = ( array ) $ type ; foreach ( $ types as $ type ) { if ( isset ( $ urlArray [ '?' ] [ $ type ] ) ) { unset ( $ urlArray [ '?' ] [ $ type ] ) ; } } $ pass = ! empty ( $ urlArray [ 'pass' ] ) ? $ urlArray [ 'pass' ] : [ ] ; $ returnArray = [ ] ; if ( is...
Removes specific query strings from parsed URL array .
43,055
public function findCloud ( Query $ query ) { $ groupBy = [ 'Tagged.tag_id' , 'Tags.id' , 'Tags.slug' , 'Tags.label' ] ; $ fields = $ groupBy ; $ fields [ 'counter' ] = $ query -> func ( ) -> count ( '*' ) ; $ options = [ 'minSize' => 10 , 'maxSize' => 20 , 'contain' => 'Tags' , 'fields' => $ fields , 'group' => $ grou...
Returns a tag cloud
43,056
public function beforeFind ( Event $ event , Query $ query , ArrayObject $ options , $ primary ) { $ order = $ query -> clause ( 'order' ) ; if ( $ order !== null ) { return $ query ; } if ( ! isset ( $ this -> order ) ) { $ contain = $ query -> getContain ( ) ; if ( ! isset ( $ contain [ $ this -> Tags -> getAlias ( )...
Sets the default ordering .
43,057
public function checkMaintenance ( $ ipAddress = null , $ exit = true ) { if ( $ ipAddress === null ) { $ ipAddress = env ( 'REMOTE_ADDRESS' ) ; } if ( ! $ this -> isMaintenanceMode ( $ ipAddress ) ) { return ; } $ Response = new Response ( ) ; $ Response -> statusCode ( 503 ) ; $ Response -> header ( 'Retry-After' , D...
Main functionality to trigger maintenance mode . Will automatically set the appropriate headers .
43,058
public function isMaintenanceMode ( $ ipAddress = null ) { if ( $ ipAddress ) { $ this -> enableDebugModeForWhitelist ( $ ipAddress ) ; } if ( ! file_exists ( $ this -> file ) ) { return false ; } $ content = file_get_contents ( $ this -> file ) ; if ( $ content === false ) { return false ; } if ( $ content > 0 && $ co...
Check if maintenance mode is on .
43,059
public function setMaintenanceMode ( $ value ) { if ( $ value === false ) { if ( ! file_exists ( $ this -> file ) ) { return true ; } return unlink ( $ this -> file ) ; } if ( $ value ) { $ value = time ( ) + $ value * MINUTE ; } return ( bool ) file_put_contents ( $ this -> file , $ value ) ; }
Set maintenance mode .
43,060
public function clearWhitelist ( $ ips = [ ] ) { $ files = glob ( TMP . 'maintenanceOverride-*.txt' ) ; foreach ( $ files as $ file ) { $ ip = pathinfo ( $ file , PATHINFO_FILENAME ) ; $ ip = substr ( $ ip , strpos ( $ ip , '-' ) + 1 ) ; if ( ! $ ips || in_array ( $ this -> _unslugIp ( $ ip ) , $ ips ) ) { if ( ! unlin...
Clear whitelist . If IPs are passed only those will be removed otherwise all .
43,061
public function setLayout ( $ layout ) { if ( ! $ layout ) { $ this -> request -> getSession ( ) -> delete ( 'Setup.layout' ) ; return ; } $ this -> request -> getSession ( ) -> write ( 'Setup.layout' , $ layout ) ; }
Set layout for this session .
43,062
public function setMaintenance ( $ maintenance ) { $ ip = env ( 'REMOTE_ADDR' ) ; $ length = ( int ) $ this -> Controller -> request -> getQuery ( 'duration' ) ; $ Maintenance = new Maintenance ( ) ; if ( ! $ Maintenance -> setMaintenanceMode ( $ maintenance ? $ length : false ) ) { return false ; } if ( ! $ Maintenanc...
Set maintance mode for everybody except for the own IP which will be whitelisted .
43,063
public function setDebug ( $ level , $ type = 'session' ) { $ level = ( int ) $ level ; if ( $ type === 'session' ) { if ( $ level < 0 ) { $ this -> request -> getSession ( ) -> delete ( 'Setup.debug' ) ; return false ; } $ this -> request -> getSession ( ) -> write ( 'Setup.debug' , $ level ) ; return true ; } $ cooki...
Override debug level
43,064
public function clearCache ( $ type = null ) { $ config = $ type ? : 'default' ; Cache :: clear ( false , $ config ) ; return true ; }
Clear cache of tmp folders
43,065
protected function _cleanedUrl ( $ type ) { $ type = ( array ) $ type ; if ( Configure :: read ( 'Config.productive' ) ) { $ type [ ] = 'pwd' ; } return Setup :: cleanedUrl ( $ type , $ this -> Controller -> request -> getAttribute ( 'params' ) + [ '?' => $ this -> Controller -> request -> getQuery ( ) ] ) ; }
Remove specific named param from parsed url array
43,066
public function folder ( ) { if ( ! empty ( $ this -> params [ 'extensions' ] ) ) { $ this -> settings [ 'files' ] = Text :: tokenize ( $ this -> params [ 'extensions' ] ) ; } if ( ! empty ( $ this -> params [ 'again' ] ) ) { $ this -> settings [ 'againWithHalf' ] = true ; } $ folder = null ; if ( ! empty ( $ this -> a...
Main execution function to indent a folder recursivly
43,067
protected function _searchFiles ( ) { foreach ( $ this -> _paths as $ path ) { $ Folder = new Folder ( $ path ) ; $ files = $ Folder -> findRecursive ( '.*\.(' . implode ( '|' , $ this -> settings [ 'files' ] ) . ')' , true ) ; foreach ( $ files as $ file ) { if ( strpos ( $ file , DS . 'Vendor' . DS ) !== false ) { co...
Search files that may contain translateable strings
43,068
public function engine ( $ engine = null ) { $ db = $ this -> _getConnection ( ) ; $ config = $ db -> config ( ) ; $ database = $ config [ 'database' ] ; $ prefix = '' ; $ engines = [ 'InnoDB' , 'MyISAM' ] ; while ( ! $ engine ) { $ engine = $ this -> in ( 'Please select target engine' , $ engines ) ; } if ( ! in_array...
Convert database table engine .
43,069
public function tablePrefix ( $ action = null , $ prefix = null ) { $ db = $ this -> _getConnection ( ) ; $ config = $ db -> config ( ) ; $ database = $ config [ 'database' ] ; if ( ! empty ( $ this -> params [ 'database' ] ) ) { $ database = $ this -> params [ 'database' ] ; } while ( ! $ action || ! in_array ( $ acti...
Adds or removes table prefixes .
43,070
public function display ( array $ tags , array $ options = [ ] , array $ attrs = [ ] ) { if ( empty ( $ tags ) ) { return '' ; } $ options += $ this -> _config ; $ tags = $ this -> calculateWeights ( $ tags ) ; $ weights = Hash :: extract ( $ tags , $ options [ 'extract' ] ) ; $ maxWeight = max ( $ weights ) ; $ minWei...
Method to output a tag - cloud formatted based on the weight of the tags
43,071
public function control ( array $ options = [ ] ) { if ( $ this -> getConfig ( 'strategy' ) === 'array' ) { $ tags = ( array ) $ this -> Form -> getSourceValue ( $ this -> getConfig ( 'field' ) ) ; $ options += [ 'options' => array_combine ( $ tags , $ tags ) , 'val' => $ tags , 'type' => 'select' , 'multiple' => true ...
Convenience method for tag list form input .
43,072
public function getFilterForRule ( Rule $ rule ) { $ filterIdentifier = $ rule -> getFilter ( ) ; if ( $ this -> container === null || ! $ this -> container -> has ( $ filterIdentifier ) ) { return parent :: getFilterForRule ( $ rule ) ; } return $ this -> container -> get ( $ filterIdentifier ) ; }
Attempts to load Filter from Container or hands off to parent loader .
43,073
public function current ( ) { if ( $ this -> currentLine === null ) { $ this -> readLine ( ) ; } try { $ data = $ this -> parser -> parseLine ( $ this -> currentLine ) ; } catch ( MatchException $ exception ) { $ data = null ; } return $ data ; }
Returns parsed current line .
43,074
public function generate ( $ path = null ) { $ path = $ this -> getPath ( $ path ) ; $ this -> out ( 'Reading ' . $ path . '.mailmap' ) ; $ existingMap = $ this -> parseMailmap ( $ path ) ; $ this -> out ( 'Found ' . count ( $ this -> map ) . ' existing entries in .mailmap file' ) ; $ rows = $ this -> parseHistory ( $ ...
Generates . mailmap file .
43,075
public function apply ( Rule $ rule , $ value ) { if ( ! $ this -> container -> has ( $ rule -> service ) ) { throw new \ RuntimeException ( "Unable to find service '{$rule->service}' to execute defined rule." ) ; } $ service = $ this -> container -> get ( $ rule -> service ) ; if ( ! \ is_callable ( [ $ service , $ ru...
Enforces the desired filtering on the the value returning a filtered value .
43,076
private function hide_promo ( ) { $ hide_promo = get_transient ( 'yoast_i18n_' . $ this -> project_slug . '_promo_hide' ) ; if ( ! $ hide_promo ) { if ( filter_input ( INPUT_GET , 'remove_i18n_promo' , FILTER_VALIDATE_INT ) === 1 ) { set_transient ( 'yoast_i18n_' . $ this -> project_slug . '_promo_hide' , true ) ; $ hi...
Check whether the promo should be hidden or not .
43,077
private function promo_message ( ) { $ this -> translation_details ( ) ; $ message = false ; if ( $ this -> translation_exists && $ this -> translation_loaded && $ this -> percent_translated < 90 ) { $ message = __ ( 'As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% co...
Generates a promo message .
43,078
public function promo ( ) { $ message = $ this -> get_promo_message ( ) ; if ( $ message ) { echo '<div id="i18n_promo_box" style="border:1px solid #ccc;background-color:#fff;padding:10px;max-width:650px; overflow: hidden;">' ; echo '<a href="' . esc_url ( add_query_arg ( array ( 'remove_i18n_promo' => '1' ) ) ) . '" s...
Outputs a promo box .
43,079
private function find_or_initialize_translation_details ( ) { $ set = get_transient ( 'yoast_i18n_' . $ this -> project_slug . '_' . $ this -> locale ) ; if ( ! $ set ) { $ set = $ this -> retrieve_translation_details ( ) ; set_transient ( 'yoast_i18n_' . $ this -> project_slug . '_' . $ this -> locale , $ set , DAY_IN...
Try to find the transient for the translation set or retrieve them .
43,080
private function translation_details ( ) { $ set = $ this -> find_or_initialize_translation_details ( ) ; $ this -> translation_exists = ! is_null ( $ set ) ; $ this -> translation_loaded = is_textdomain_loaded ( $ this -> textdomain ) ; $ this -> parse_translation_set ( $ set ) ; }
Try to get translation details from cache otherwise retrieve them then parse them .
43,081
private function get_api_url ( ) { if ( empty ( $ this -> api_url ) ) { $ this -> api_url = trailingslashit ( $ this -> glotpress_url ) . 'api/projects/' . $ this -> project_slug ; } return $ this -> api_url ; }
Returns the API URL to use when requesting translation information .
43,082
private function retrieve_translation_details ( ) { $ api_url = $ this -> get_api_url ( ) ; $ resp = wp_remote_get ( $ api_url ) ; if ( is_wp_error ( $ resp ) || wp_remote_retrieve_response_code ( $ resp ) !== 200 ) { return null ; } $ body = wp_remote_retrieve_body ( $ resp ) ; unset ( $ resp ) ; if ( $ body ) { $ bod...
Retrieve the translation details from Yoast Translate .
43,083
private function parse_translation_set ( $ set ) { if ( $ this -> translation_exists && is_object ( $ set ) ) { $ this -> locale_name = $ set -> name ; $ this -> percent_translated = $ set -> percent_translated ; } else { $ this -> locale_name = '' ; $ this -> percent_translated = '' ; } }
Set the needed private variables based on the results from Yoast Translate .
43,084
private function set_defaults ( $ args ) { if ( ! isset ( $ args [ 'glotpress_logo' ] ) ) { $ args [ 'glotpress_logo' ] = 'https://plugins.svn.wordpress.org/' . $ args [ 'textdomain' ] . '/assets/icon-128x128.png' ; } if ( ! isset ( $ args [ 'register_url' ] ) ) { $ args [ 'register_url' ] = 'https://translate.wordpres...
Sets the default values for wordpress . org
43,085
public function socialNetworks ( ) { if ( $ this -> socialNetworks ) { return $ this -> socialNetworks ; } $ socials = json_decode ( $ this -> cmsConfig ( ) [ 'social_medias' ] , true ) ; $ configMeta = $ this -> configModel ( ) -> p ( 'social_medias' ) -> structureMetadata ( ) ; foreach ( $ socials as $ ident => $ acc...
Retrieve the websites s social presence .
43,086
protected function addAttachmentGroupFromMetadata ( $ reload = false ) { if ( $ this -> obj ( ) instanceof TemplateableInterface ) { $ this -> setControllerIdent ( $ this -> obj ( ) -> templateIdentClass ( ) ) ; } if ( $ reload || ! $ this -> isAttachmentMetadataFinalized ) { $ obj = $ this -> obj ( ) ; $ controllerInt...
Load attachments group widget and them as form groups .
43,087
public function setControllerIdent ( $ ident ) { if ( class_exists ( $ ident ) ) { $ this -> controllerIdent = $ ident ; return $ this ; } if ( substr ( $ ident , - 9 ) !== '-template' ) { $ ident .= '-template' ; } $ this -> controllerIdent = $ ident ; return $ this ; }
Set the form object s template controller identifier .
43,088
public static function load ( $ class_name ) { $ file_name = str_replace ( self :: MOLLIE_PREFIX , '' , strtolower ( $ class_name ) , $ count ) ; if ( empty ( $ count ) ) { return ; } if ( file_exists ( $ file_name = __DIR__ . DIRECTORY_SEPARATOR . "$file_name.php" ) ) { require $ file_name ; } }
Uses require_once to load the Mollie class .
43,089
public function entries ( ) { $ page = $ this -> page ( ) ; $ cat = $ this -> category ( ) ; if ( isset ( $ this -> entries [ $ cat ] ) ) { if ( isset ( $ this -> entries [ $ cat ] [ $ page ] ) ) { return $ this -> entries [ $ cat ] [ $ page ] ; } } $ loader = $ this -> entriesLoader ( ) ; $ this -> entries [ $ cat ] [...
To be displayed news list .
43,090
public function all ( ) { if ( $ this -> all ) { return $ this -> all ; } $ this -> all = $ this -> loader ( ) -> all ( ) -> addOrder ( 'news_date' , 'desc' ) -> load ( ) ; return $ this -> all ; }
All available news .
43,091
public function setPrevNext ( ) { if ( $ this -> nextNews && $ this -> prevNews ) { return $ this ; } $ entries = $ this -> entries ( ) ; $ isPrev = false ; $ isNext = false ; $ firstNews = false ; $ lastNews = false ; foreach ( $ entries as $ news ) { if ( ! $ firstNews ) { $ firstNews = $ news ; } $ lastNews = $ news...
Set the Prev and Next news
43,092
public function addTypeError ( $ value , $ type = '' ) { $ type = $ type ? : $ this -> getType ( ) ; $ this -> validation -> addError ( $ this -> getName ( ) , 'type' , [ 'type' => $ type , 'value' => is_scalar ( $ value ) ? $ value : null , 'messageCode' => is_scalar ( $ value ) ? "{value} is not a valid $type." : "Th...
Add an invalid type error .
43,093
public function merge ( Validation $ validation ) { $ this -> getValidation ( ) -> merge ( $ validation , $ this -> getName ( ) ) ; return $ this ; }
Merge a validation object to this one .
43,094
public function hasVal ( $ key ) { return isset ( $ this -> field [ $ key ] ) || ( is_array ( $ this -> field ) && array_key_exists ( $ key , $ this -> field ) ) ; }
Whether or not the field has a value .
43,095
public function sectionRoutes ( ) { if ( $ this -> sectionRoutes ) { return $ this -> sectionRoutes ; } $ proto = $ this -> modelFactory ( ) -> create ( ObjectRoute :: class ) ; $ sectionTypes = $ this -> sectionTypes ( ) ; if ( empty ( $ sectionTypes ) ) { $ sectionTypes = [ 'base' => $ this -> objType ( ) ] ; } $ loa...
Pair routes slug to sections ID
43,096
public function resolveRoute ( $ route ) { $ routes = $ this -> sectionRoutes ( ) ; $ sId = $ this -> resolveSectionId ( $ route ) ; if ( ! isset ( $ routes [ 'sections' ] [ $ sId ] ) ) { return '' ; } return $ routes [ 'sections' ] [ $ sId ] ; }
Resolve latest route from route slug .
43,097
public function generateDefaultMetaTags ( ) { if ( $ this -> isEmptyMeta ( $ this -> metaTitle ) ) { $ this -> setMetaTitle ( $ this -> defaultMetaTitle ( ) ) ; } if ( $ this -> isEmptyMeta ( $ this -> metaDescription ) ) { $ this -> setMetaDescription ( $ this -> defaultMetaDescription ( ) ) ; } if ( $ this -> isEmpty...
Generates the default metatags for the current object . Prevents some problem where the defaultMetaTag method content isn t set at the moment of setting the meta . Should be called on preSave and preUpdate of the object .
43,098
protected function getContextObject ( ) { if ( $ this -> contextObject === null ) { $ this -> contextObject = $ this -> loadContextObject ( ) ; } return $ this -> contextObject ; }
Get the object associated with the matching object route .
43,099
protected function loadContextObject ( ) { $ route = $ this -> getObjectRouteFromPath ( ) ; $ obj = $ this -> modelFactory ( ) -> create ( $ route -> routeObjType ( ) ) ; $ obj -> load ( $ route -> routeObjId ( ) ) ; return $ obj ; }
Load the object associated with the matching object route .