idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
12,400 | protected function container ( Table $ table , array $ rows , array $ headers , array $ footers ) { $ html = '<table' ; $ this -> addAttributes ( $ html , $ table -> getAttributes ( ) ) ; $ html .= '><thead>' ; $ html .= implode ( "\n" , $ headers ) ; $ html .= '</thead><tbody>' ; $ html .= implode ( "\n" , $ rows ) ; ... | Generates a correct table tag to contain the rendered rows |
12,401 | protected function row ( Row $ row , array $ cells ) { $ html = '<tr' ; $ this -> addAttributes ( $ html , $ row -> getAttributes ( ) ) ; $ html .= '>' . implode ( '' , $ cells ) . '</tr>' ; return $ html ; } | Generates a tr with the given rendered cells |
12,402 | protected function cell ( Cell $ cell ) { $ html = '<td' ; $ this -> addAttributes ( $ html , $ cell -> getAttributes ( ) ) ; $ html .= '>' . $ cell -> getContent ( ) . '</td>' ; return $ html ; } | Creates a td tag using the given Cell |
12,403 | protected function addAttributes ( & $ html , array $ attributes ) { if ( count ( $ attributes ) > 0 ) { $ attributes = Html :: arrayToAttributes ( $ attributes ) ; $ html .= ' ' . $ attributes ; } } | Helper function to convert an array into a list of attributes and append them to a string |
12,404 | public function add ( DateInterval $ interval ) { $ years = $ this -> y + $ interval -> y ; $ months = $ this -> m + $ interval -> m ; $ days = $ this -> d + $ interval -> d ; $ hours = $ this -> h + $ interval -> h ; $ minutes = $ this -> i + $ interval -> i ; $ seconds = $ this -> s + $ interval -> s ; $ spec = sprin... | Creates a DateInterval object by adding another interval into it . Uses absolute values for addition process . |
12,405 | public function equals ( DateInterval $ interval ) { $ years = $ this -> y == $ interval -> y ; $ months = $ this -> m == $ interval -> m ; $ days = $ this -> d == $ interval -> d ; $ hours = $ this -> h == $ interval -> h ; $ minutes = $ this -> i == $ interval -> i ; $ seconds = $ this -> s == $ interval -> s ; $ inv... | Checks if the current interval is equals to the interval given as parameter . |
12,406 | public function invert ( ) { $ interval = $ this -> copy ( $ this -> interval ) ; $ interval -> invert = $ interval -> invert ? 0 : 1 ; return new DateInterval ( $ interval ) ; } | Creates a DateInterval object by inverting the value of the current one . |
12,407 | private function copy ( \ DateInterval $ interval ) { $ copy = new \ DateInterval ( $ interval -> format ( 'P%yY%mM%dDT%hH%iM%sS' ) ) ; $ copy -> invert = $ interval -> invert ; return $ copy ; } | Creates a copy of PHP DateInterval object . |
12,408 | public function updateOrderStatus ( OrderEvent $ event ) { $ paybox = new Paybox ( ) ; if ( $ event -> getOrder ( ) -> isPaid ( ) && $ paybox -> isPaymentModuleFor ( $ event -> getOrder ( ) ) ) { $ contact_email = ConfigQuery :: read ( 'store_email' , false ) ; Tlog :: getInstance ( ) -> debug ( "Order " . $ event -> g... | Checks if we are the payment module for the order and if the order is paid then send a confirmation email to the customer . |
12,409 | public function checkSendOrderConfirmationMessageToCustomer ( OrderEvent $ event ) { if ( Paybox :: getConfigValue ( 'send_confirmation_email_on_successful_payment' , false ) ) { $ paybox = new Paybox ( ) ; if ( $ paybox -> isPaymentModuleFor ( $ event -> getOrder ( ) ) ) { if ( ! $ event -> getOrder ( ) -> isPaid ( ) ... | Send the confirmation message only if the order is paid . |
12,410 | public function setFile ( $ file ) { $ f = $ file ; if ( preg_match ( '#^compress\.(.*)://(.*)#' , $ file , $ r ) ) { $ f = $ r [ 2 ] ; } if ( is_readable ( $ f ) ) { $ open = fopen ( $ file , "rb" ) ; $ this -> file = $ open ; } else { $ this -> handleError ( "{$file} is not readable." ) ; } } | Set the file and open up a steam . If the file cannot be opened for reading throw an error . |
12,411 | protected function validateField ( $ fieldIdentifier ) { $ field = $ this -> translationHelper -> getTranslatedField ( $ this -> content , $ fieldIdentifier ) ; if ( ! $ field instanceof Field ) { throw new InvalidArgumentException ( '$params[0]' , 'Field \'' . $ fieldIdentifier . '\' does not exist in content.' ) ; } ... | Validates field by field identifier . |
12,412 | public function parse ( $ string , array $ whitelist = array ( ) , $ wrap = true ) { $ parsed = $ this -> getDecoda ( ) -> reset ( $ string ) -> whitelist ( $ whitelist ) -> parse ( ) ; if ( $ wrap ) { return $ this -> Html -> div ( 'decoda' , $ parsed ) ; } return $ parsed ; } | Reset the Decoda instance apply any whitelisted tags and executes the parsing process . |
12,413 | public function strip ( $ string , $ html = false ) { return $ this -> getDecoda ( ) -> reset ( $ string ) -> strip ( $ html ) ; } | Reset the Decoda instance and strip out any Decoda tags and HTML . |
12,414 | protected function _getOssClient ( $ path ) { if ( $ this -> _oss === null ) { $ url = explode ( ':' , $ path ) ; if ( empty ( $ url ) ) { throw new Exception ( "Unable to parse URL $path" ) ; } $ this -> _oss = AliyunOSS :: getWrapperClient ( $ url [ 0 ] ) ; if ( ! $ this -> _oss ) { throw new Exception ( "Unknown cli... | Retrieve client for this stream type . |
12,415 | protected function _getNamePart ( $ path ) { $ url = parse_url ( $ path ) ; if ( $ url [ 'host' ] ) { return ! empty ( $ url [ 'path' ] ) ? $ url [ 'host' ] . $ url [ 'path' ] : $ url [ 'host' ] ; } return '' ; } | Extract object name from URL . |
12,416 | public function stream_open ( $ path , $ mode , $ options , & $ opened_path ) { $ name = $ this -> _getNamePart ( $ path ) ; if ( strpbrk ( $ mode , 'wax' ) ) { $ this -> _objectName = $ name ; $ this -> _objectBuffer = null ; $ this -> _objectSize = 0 ; $ this -> _position = 0 ; $ this -> _writeBuffer = true ; $ this ... | Open the stream . |
12,417 | public function stream_close ( ) { $ this -> _objectName = null ; $ this -> _objectBuffer = null ; $ this -> _objectSize = 0 ; $ this -> _position = 0 ; $ this -> _writeBuffer = false ; unset ( $ this -> _oss ) ; } | Close the stream . |
12,418 | public function stream_read ( $ count ) { if ( ! $ this -> _objectName ) { return '' ; } if ( $ count + $ this -> _position > $ this -> _objectSize ) { $ count = $ this -> _objectSize - $ this -> _position ; } $ range_start = $ this -> _position ; $ range_end = $ this -> _position + $ count - 1 ; if ( ( $ this -> _posi... | Read from the stream . |
12,419 | public function stream_write ( $ data ) { if ( ! $ this -> _objectName ) { return 0 ; } $ len = strlen ( $ data ) ; $ this -> _objectBuffer .= $ data ; $ this -> _objectSize += $ len ; return $ len ; } | Write to the stream . |
12,420 | public function stream_flush ( ) { if ( ! $ this -> _writeBuffer ) { return false ; } $ ret = $ this -> _oss -> putObject ( AliyunOSS :: getBucket ( ) , $ this -> _objectName , $ this -> _objectBuffer ) ; $ this -> _objectBuffer = null ; return $ ret ; } | Flush current cached stream data to storage . |
12,421 | public function stream_stat ( ) { if ( ! $ this -> _objectName ) { return [ ] ; } $ stat = [ ] ; $ stat [ 'dev' ] = 0 ; $ stat [ 'ino' ] = 0 ; $ stat [ 'mode' ] = 0777 ; $ stat [ 'nlink' ] = 0 ; $ stat [ 'uid' ] = 0 ; $ stat [ 'gid' ] = 0 ; $ stat [ 'rdev' ] = 0 ; $ stat [ 'size' ] = 0 ; $ stat [ 'atime' ] = 0 ; $ stat... | Returns data array of stream variables . |
12,422 | public function unlink ( $ path ) { return $ this -> _getOssClient ( $ path ) -> deleteObject ( AliyunOSS :: getBucket ( ) , $ this -> _getNamePart ( $ path ) ) ; } | Attempt to delete the item . |
12,423 | public function dir_readdir ( ) { $ object = current ( $ this -> _bucketList ) ; if ( $ object !== false ) { next ( $ this -> _bucketList ) ; } return $ object ; } | Return the next filename in the directory . |
12,424 | public function dir_opendir ( $ path , $ options ) { $ dirName = $ this -> _getNamePart ( $ path ) . '/' ; if ( preg_match ( '@^([a-z0-9+.]|-)+://$@' , $ path ) || $ dirName == '/' ) { $ list = $ this -> _getOssClient ( $ path ) -> listObjects ( AliyunOSS :: getBucket ( ) ) ; } else { $ list = $ this -> _getOssClient (... | Attempt to open a directory . |
12,425 | public function url_stat ( $ path , $ flags ) { $ stat = [ 'dev' => 0 , 'ino' => 0 , 'mode' => 0777 , 'nlink' => 0 , 'uid' => 0 , 'gid' => 0 , 'rdev' => 0 , 'size' => 0 , 'atime' => 0 , 'mtime' => 0 , 'ctime' => 0 , 'blksize' => 0 , 'blocks' => 0 , ] ; $ name = $ this -> _getNamePart ( $ path ) ; try { $ info = $ this ... | Return array of URL variables . |
12,426 | public function validate ( Model $ model , $ set ) { if ( ! isset ( $ model -> validations [ $ set ] ) ) { throw new OutOfBoundsException ( sprintf ( 'Validation set %s does not exist' , $ set ) ) ; } $ rules = $ model -> validations [ $ set ] ; $ settings = $ this -> settings [ $ model -> alias ] ; if ( $ settings [ '... | Set the validation set to use . |
12,427 | public function invalid ( Model $ model , $ field , $ message , $ params = array ( ) ) { $ model -> invalidate ( $ field , __d ( $ model -> validationDomain ? : 'default' , $ message , $ params ) ) ; return false ; } | Convenience method to invalidate a field and translate the custom message . |
12,428 | public function beforeValidate ( Model $ model , $ options = array ( ) ) { $ default = $ this -> settings [ $ model -> alias ] [ 'defaultSet' ] ; if ( empty ( $ model -> validate ) && isset ( $ model -> validations [ $ default ] ) ) { $ this -> validate ( $ model , $ default ) ; } return true ; } | If validate is empty and a default set exists apply the rules . |
12,429 | protected function _applyMessages ( Model $ model , array $ rules ) { foreach ( $ rules as $ key => $ value ) { if ( is_array ( $ value ) ) { if ( $ key !== 'rule' ) { $ rules [ $ key ] = $ this -> _applyMessages ( $ model , $ value ) ; } } else if ( isset ( $ this -> _messages [ $ value ] ) && $ key !== 'rule' ) { $ r... | Apply and set default messages if they are missing . |
12,430 | protected function isParentItem ( $ line ) { if ( $ this -> _listDepth === 1 || ( $ marker = $ line [ 0 ] ) !== '*' && $ marker !== '#' ) { return false ; } $ depthMax = $ this -> _listDepth - 1 ; if ( preg_match ( '/^(#{1,' . $ depthMax . '})[^#]+/' , $ line , $ matches ) ) { return $ this -> _nestedListTypes [ strlen... | check if a line is an item that belongs to a parent list |
12,431 | protected function isSiblingItem ( $ line ) { $ siblingMarker = $ this -> _nestedListTypes [ $ this -> _listDepth ] == 'ol' ? '*' : '#' ; if ( $ line [ 0 ] !== $ siblingMarker ) { return false ; } return ( $ siblingMarker === '#' && preg_match ( '/^#{' . $ this -> _listDepth . '}[^#]+/' , $ line ) ) || ( $ siblingMarke... | check if a line is an item that belongs to a sibling list |
12,432 | public function notify ( Model $ model , $ data , $ status , $ points = 0 ) { $ settings = $ this -> settings [ $ model -> alias ] ; $ columnMap = $ settings [ 'columnMap' ] ; if ( $ settings [ 'model' ] && $ settings [ 'link' ] && $ settings [ 'email' ] ) { $ Article = ClassRegistry :: init ( Inflector :: classify ( $... | Sends out an email notifying you of a new comment . |
12,433 | public function main ( ) { $ this -> stdout -> styles ( 'success' , array ( 'text' => 'green' ) ) ; $ this -> hr ( 1 ) ; $ this -> out ( sprintf ( '%s Steps:' , $ this -> name ) ) ; $ counter = 1 ; foreach ( $ this -> steps as $ method ) { $ this -> steps ( $ counter ) ; try { if ( ! call_user_func ( array ( $ this , $... | Execute installer and cycle through all steps . |
12,434 | public function checkDbConfig ( ) { if ( ! $ this -> dbConfig || ! $ this -> db ) { $ dbConfigs = array_keys ( get_class_vars ( 'DATABASE_CONFIG' ) ) ; $ this -> out ( 'Available database configurations:' ) ; foreach ( $ dbConfigs as $ i => $ db ) { $ this -> out ( sprintf ( '[%s] <info>%s</info>' , $ i , $ db ) ) ; } ... | Check the database status before installation . |
12,435 | public function checkRequiredTables ( ) { if ( $ this -> requiredTables ) { $ this -> out ( sprintf ( 'The following tables are required: <info>%s</info>' , implode ( ', ' , $ this -> requiredTables ) ) ) ; $ this -> out ( '<success>Checking tables...</success>' ) ; $ tables = $ this -> db -> listSources ( ) ; $ missin... | Check that all the required tables exist in the database . |
12,436 | public function checkUsersModel ( ) { if ( ! $ this -> usersModel ) { $ this -> setUsersModel ( $ this -> in ( 'What is the name of your users model?' ) ) ; } $ this -> out ( sprintf ( 'Users Model: <info>%s</info>' , $ this -> usersModel ) ) ; $ answer = strtoupper ( $ this -> in ( 'Is this correct?' , array ( 'Y' , '... | Determine the users model to use . |
12,437 | public function checkUsersTable ( ) { if ( ! $ this -> usersTable ) { $ this -> setUsersTable ( $ this -> in ( 'What is the name of your users table?' ) ) ; } $ this -> out ( sprintf ( 'Users Table: <info>%s</info>' , $ this -> usersTable ) ) ; $ answer = strtoupper ( $ this -> in ( 'Is this correct?' , array ( 'Y' , '... | Determine the users table to use . |
12,438 | public function createTables ( ) { $ answer = strtoupper ( $ this -> in ( 'Existing tables will be deleted, continue?' , array ( 'Y' , 'N' ) ) ) ; if ( $ answer === 'N' ) { return false ; } $ schemas = glob ( CakePlugin :: path ( $ this -> plugin ) . '/Config/Schema/*.sql' ) ; $ executed = 0 ; $ tables = array ( ) ; $ ... | Create the database tables based off the schemas . |
12,439 | public function createUser ( ) { $ data = array ( ) ; foreach ( $ this -> userFields as $ base => $ field ) { $ data [ $ field ] = $ this -> getFieldInput ( $ base ) ; } $ model = ClassRegistry :: init ( $ this -> usersModel ) ; $ model -> create ( ) ; $ model -> save ( $ data , false ) ; $ this -> config = $ data ; $ ... | Gather all the data for creating a new user . |
12,440 | public function executeSchema ( $ path , $ track = true ) { if ( ! file_exists ( $ path ) ) { throw new DomainException ( sprintf ( '<error>Schema %s does not exist</error>' , basename ( $ path ) ) ) ; } $ contents = file_get_contents ( $ path ) ; $ contents = String :: insert ( $ contents , array ( 'prefix' => $ this ... | Execute a schema SQL file using the loaded datasource . |
12,441 | public function findUser ( ) { $ model = ClassRegistry :: init ( $ this -> usersModel ) ; $ id = trim ( $ this -> in ( 'User ID:' ) ) ; if ( ! $ id ) { $ this -> out ( '<error>Invalid ID, please try again</error>' ) ; return $ this -> findUser ( ) ; } $ result = $ model -> find ( 'first' , array ( 'conditions' => array... | Find a user within the users table . |
12,442 | public function setDbConfig ( $ config ) { $ this -> dbConfig = $ config ; $ this -> db = ConnectionManager :: getDataSource ( $ config ) ; $ this -> db -> cacheSources = false ; return $ this ; } | Set the database config to use and load the data source . |
12,443 | public function setRequiredTables ( array $ tables ) { $ this -> requiredTables = array_unique ( array_merge ( $ this -> requiredTables , $ tables ) ) ; return $ this ; } | Set the required tables . |
12,444 | public function setUserFields ( array $ fields ) { $ clean = array ( ) ; foreach ( $ fields as $ base => $ field ) { if ( is_numeric ( $ base ) ) { $ base = $ field ; } $ clean [ $ base ] = $ field ; } $ this -> userFields = $ clean ; return $ this ; } | Set the user fields mapping . |
12,445 | public function steps ( $ step = 0 ) { $ this -> hr ( 1 ) ; $ counter = 1 ; foreach ( $ this -> steps as $ title => $ method ) { if ( $ counter < $ step ) { $ this -> out ( '[x] ' . $ title ) ; } else { $ this -> out ( sprintf ( '[%s] <info>%s</info>' , $ counter , $ title ) ) ; } $ counter ++ ; } $ this -> out ( ) ; } | Table of contents . |
12,446 | protected function doPay ( Order $ order ) { if ( 'TEST' == Paybox :: getConfigValue ( 'mode' , false ) ) { $ platformUrl = Paybox :: getConfigValue ( 'url_serveur_test' , false ) ; } else { $ platformUrl = Paybox :: getConfigValue ( 'url_serveur' , false ) ; } if ( false === $ platformUrl ) { throw new \ InvalidArgume... | Payment gateway invocation |
12,447 | protected function getCurrencyIso4217NumericCode ( $ textCurrencyCode ) { $ currencies = null ; $ localIso417data = __DIR__ . DS . "Config" . DS . "iso4217.xml" ; $ currencyXmlDataUrl = "http://www.currency-iso.org/dam/downloads/lists/list_one.xml" ; $ xmlData = @ file_get_contents ( $ currencyXmlDataUrl ) ; try { $ cu... | Get the numeric ISO 4217 code of a currency |
12,448 | protected function getHashAlgorithm ( ) { $ hashes = [ 'sha512' , 'sha256' , 'sha384' , 'ripemd160' , 'sha224' , 'mdc2' ] ; $ hashEnabled = hash_algos ( ) ; foreach ( $ hashes as $ hash ) { if ( in_array ( $ hash , $ hashEnabled ) ) { return strtoupper ( $ hash ) ; } } throw new \ RuntimeException ( Translator :: getIn... | Find a suitable hashing algorithm |
12,449 | public function addCell ( $ content , $ attributes = array ( ) ) { $ currentRow = $ this -> getCurrentRow ( ) ; if ( $ content instanceof Cell ) { $ currentRow [ ] = $ content ; } else { $ currentRow [ ] = $ this -> constructCell ( $ content , $ attributes ) ; } return $ this ; } | Adds a Cell to the current Row |
12,450 | protected function constructCell ( $ content = null , $ attributes = array ( ) ) { $ cell = new Cell ( $ content ) ; $ cell -> setAttributes ( $ attributes ) ; return $ cell ; } | Creates a new Cell with the given content |
12,451 | public function createRow ( $ type = EnumRowType :: Body ) { $ this -> currentRow = new Row ; $ this -> currentRow -> setType ( $ type ) ; return $ this ; } | Creates a new Row object and assigns it as the currently active row |
12,452 | public function addRow ( ) { switch ( $ this -> currentRow -> getType ( ) ) { case EnumRowType :: Body : $ this -> rows [ ] = $ this -> currentRow ; break ; case EnumRowType :: Header : $ this -> headerRows [ ] = $ this -> currentRow ; break ; case EnumRowType :: Footer : $ this -> footerRows [ ] = $ this -> currentRow... | Adds the Row that s currently being constructed to the list of finished Rows |
12,453 | public function actionListen ( $ queueName = null , $ queueObjectName = 'queue' ) { while ( true ) { if ( $ this -> timeout !== null ) { if ( $ this -> timeout < time ( ) ) { return true ; } } if ( ! $ this -> process ( $ queueName , $ queueObjectName ) ) { sleep ( $ this -> sleep ) ; } } } | Continuously process jobs |
12,454 | public static function create ( $ path = '' , array $ server = array ( ) , array $ globals = array ( ) ) { $ globals = empty ( $ globals ) ? $ GLOBALS : $ globals ; $ server = empty ( $ server ) ? $ _SERVER : $ server ; $ sparkplug = new SparkPlug ( $ globals , $ server , $ path ) ; return $ sparkplug -> getCodeIgniter... | Creates an instance of CodeIgniter based on the application path . |
12,455 | public function formatBytes ( $ bytes = 0 , $ decimals = 0 ) { static $ quant = array ( 'TB' => 1099511627776 , 'GB' => 1073741824 , 'MB' => 1048576 , 'KB' => 1024 , 'B ' => 1 , ) ; foreach ( $ quant as $ unit => $ mag ) { if ( doubleval ( $ bytes ) >= $ mag ) { return sprintf ( '%01.' . $ decimals . 'f' , ( $ bytes / ... | Converts a number of bytes to a human readable number by taking the number of that unit that the bytes will go into it . Supports TB value . |
12,456 | public function format ( $ string , $ format ) { if ( empty ( $ format ) or empty ( $ string ) ) { return $ string ; } $ result = '' ; $ fpos = 0 ; $ spos = 0 ; while ( ( strlen ( $ format ) - 1 ) >= $ fpos ) { if ( ctype_alnum ( substr ( $ format , $ fpos , 1 ) ) ) { $ result .= substr ( $ string , $ spos , 1 ) ; $ sp... | Formats a number by injecting non - numeric characters in a specified format into the string in the positions they appear in the format . |
12,457 | private function calc ( DateTime $ base , DateTime $ datetime = null , $ detailLevel = 1 ) { $ this -> translator = $ base -> getTranslator ( ) ; $ datetime = is_null ( $ datetime ) ? DateTime :: now ( ) : $ datetime ; $ detailLevel = intval ( $ detailLevel ) ; $ diff = $ this -> diffInUnits ( $ base -> diff ( $ dateti... | Calculates the difference between dates . |
12,458 | private function diffInUnits ( DateInterval $ interval , $ detailLevel ) { $ units = array ( 'y' => 'year' , 'm' => 'month' , 'd' => 'day' , 'h' => 'hour' , 'i' => 'minute' , 's' => 'second' ) ; $ diff = array ( ) ; foreach ( $ units as $ format => $ unit ) { $ amount = $ interval -> format ( '%' . $ format ) ; if ( $ ... | Calculates the difference between dates for all units of a time . |
12,459 | private function parseUnits ( $ diff , $ allowAlmost = false ) { if ( empty ( $ diff ) ) { return '' ; } $ isAlmost = false ; $ string = array ( ) ; foreach ( $ diff as $ time ) { if ( $ allowAlmost ) { $ isAlmost = $ this -> isAlmost ( $ time ) ; } $ string [ ] = $ this -> translator -> choice ( $ time [ 'unit' ] , $ ... | Parses an array of units into a string . |
12,460 | public function email ( ) { $ this -> raw ( ) ; $ email = null ; $ person = $ this -> person ( ) ; if ( isset ( $ person -> emails ) ) { if ( isset ( $ person -> emails -> email ) ) { if ( is_array ( $ person -> emails -> email ) && isset ( $ person -> emails -> email [ 0 ] ) ) { $ email = $ person -> emails -> email [... | Grabs the users email if it s set and available |
12,461 | public function fullName ( ) { $ this -> raw ( ) ; $ details = $ this -> person ( ) -> name ; return $ details -> { 'given-names' } -> value . ( $ details -> { 'family-name' } ? ' ' . $ details -> { 'family-name' } -> value : '' ) ; } | Grabs the raw name elements to create fullname |
12,462 | public static function today ( $ timeZone = null ) { $ now = null ; $ before = null ; if ( is_null ( $ timeZone ) ) { $ now = new \ DateTime ( ) ; $ before = new \ DateTime ( ) ; } else { $ now = new \ DateTime ( "now" , new \ DateTimeZone ( $ timeZone ) ) ; $ before = new \ DateTime ( "now" , new \ DateTimeZone ( $ ti... | return Range object set to today |
12,463 | public static function thisWeek ( $ timeZone = null , $ startOfWeek = 0 ) { $ now = null ; $ before = null ; if ( is_null ( $ timeZone ) ) { $ now = new \ DateTime ( ) ; $ before = new \ DateTime ( ) ; } else { $ now = new \ DateTime ( "now" , new \ DateTimeZone ( $ timeZone ) ) ; $ before = new \ DateTime ( "now" , ne... | return Range object set to this week |
12,464 | public static function lastWeek ( $ timeZone = null , $ startOfWeek = 0 ) { $ now = null ; $ before = null ; if ( is_null ( $ timeZone ) ) { $ now = new \ DateTime ( ) ; $ before = new \ DateTime ( ) ; } else { $ now = new \ DateTime ( "now" , new \ DateTimeZone ( $ timeZone ) ) ; $ before = new \ DateTime ( "now" , ne... | return Range object set to last week |
12,465 | public static function thisMonth ( $ timeZone = null ) { $ now = null ; $ before = null ; if ( is_null ( $ timeZone ) ) { $ now = new \ DateTime ( ) ; $ before = new \ DateTime ( ) ; } else { $ now = new \ DateTime ( "now" , new \ DateTimeZone ( $ timeZone ) ) ; $ before = new \ DateTime ( "now" , new \ DateTimeZone ( ... | return Range object set to this month |
12,466 | public static function sort ( array $ data , $ key , $ order = null ) { uasort ( $ data , function ( $ a , $ b ) use ( $ key ) { $ a_val = Arrch :: extractValues ( $ a , $ key ) ; $ b_val = Arrch :: extractValues ( $ b , $ key ) ; if ( is_string ( $ a_val ) && is_string ( $ b_val ) ) { return strcasecmp ( $ a_val , $ b... | Sorts an array of objects by the specified key . |
12,467 | public static function where ( array $ data , array $ conditions = array ( ) ) { foreach ( $ conditions as $ condition ) { if ( ! is_array ( $ condition ) ) { trigger_error ( 'Condition ' . var_export ( $ condition , true ) . ' must be an array!' , E_USER_ERROR ) ; } else { array_map ( function ( $ item , $ key ) use (... | Evaluates an object based on an array of conditions passed into the function formatted like so ... |
12,468 | public static function extractValues ( $ item , $ key ) { $ results = array ( ) ; $ item = is_object ( $ item ) ? ( array ) $ item : $ item ; $ keys = strstr ( $ key , static :: $ key_split ) ? explode ( static :: $ key_split , $ key ) : array ( $ key ) ; $ keys = array_filter ( $ keys ) ; $ key_count = count ( $ keys ... | Finds the requested value in a multidimensional array or an object and returns it . |
12,469 | public static function merge ( ) { $ args = func_get_args ( ) ; $ where = array ( ) ; $ options = array ( ) ; foreach ( $ args as $ o ) { $ options = array_merge ( $ options , $ o ) ; if ( isset ( $ o [ 'where' ] ) ) { if ( count ( $ where ) === 0 ) { $ where = $ o [ 'where' ] ; } else { foreach ( $ o [ 'where' ] as $ ... | Recursive array merge for options arrays to eliminate duplicates in a smart manner using a variable number of array arguments . |
12,470 | protected function sendPaymentNotification ( $ orderId , $ orderReference , $ paymentStatus , $ payboxMessage ) { $ this -> getMailer ( ) -> sendEmailToShopManagers ( Paybox :: NOTIFICATION_MESSAGE_NAME , [ 'order_ref' => $ orderReference , 'order_id' => $ orderId , 'paybox_payment_status' => $ paymentStatus , 'paybox_... | Send the payment notification email to the shop admin |
12,471 | private function _writeLine ( $ pFileHandle = null , $ pValues = null ) { if ( is_array ( $ pValues ) ) { $ writeDelimiter = false ; $ line = '' ; foreach ( $ pValues as $ element ) { $ element = str_replace ( $ this -> _enclosure , $ this -> _enclosure . $ this -> _enclosure , $ element ) ; if ( $ writeDelimiter ) { $... | Write line to CSV file |
12,472 | public function to ( $ version ) { $ this -> out ( sprintf ( '<success>Upgrading to %s...</success>' , $ version ) ) ; $ schema = sprintf ( '%s/Config/Schema/Upgrade/%s.sql' , CakePlugin :: path ( $ this -> plugin ) , $ version ) ; if ( ! file_exists ( $ schema ) ) { $ this -> err ( sprintf ( '<error>Upgrade schema %s ... | Upgrade to a specific version and trigger any migration callbacks . |
12,473 | public function versions ( ) { $ this -> hr ( 1 ) ; $ versions = array ( ) ; if ( $ this -> versions ) { foreach ( $ this -> versions as $ version => $ title ) { if ( in_array ( $ version , $ this -> complete ) ) { $ this -> out ( '[x] ' . $ title ) ; } else { $ this -> out ( sprintf ( '[%s] <info>%s</info>' , $ versio... | Output a list of available version to upgrade to . |
12,474 | private function _readRecordData ( $ data , $ pos , $ len ) { $ data = substr ( $ data , $ pos , $ len ) ; if ( $ this -> _encryption == self :: MS_BIFF_CRYPTO_NONE || $ pos < $ this -> _encryptionStartPos ) { return $ data ; } $ recordData = '' ; if ( $ this -> _encryption == self :: MS_BIFF_CRYPTO_RC4 ) { $ oldBlock ... | Read record data from stream decrypting as required |
12,475 | private function _readHeader ( ) { $ length = self :: _GetInt2d ( $ this -> _data , $ this -> _pos + 2 ) ; $ recordData = $ this -> _readRecordData ( $ this -> _data , $ this -> _pos + 4 , $ length ) ; $ this -> _pos += 4 + $ length ; if ( ! $ this -> _readDataOnly ) { if ( $ recordData ) { if ( $ this -> _version == s... | Read HEADER record |
12,476 | private function _readHcenter ( ) { $ length = self :: _GetInt2d ( $ this -> _data , $ this -> _pos + 2 ) ; $ recordData = $ this -> _readRecordData ( $ this -> _data , $ this -> _pos + 4 , $ length ) ; $ this -> _pos += 4 + $ length ; if ( ! $ this -> _readDataOnly ) { $ isHorizontalCentered = ( bool ) self :: _GetInt... | Read HCENTER record |
12,477 | private function _readPageSetup ( ) { $ length = self :: _GetInt2d ( $ this -> _data , $ this -> _pos + 2 ) ; $ recordData = $ this -> _readRecordData ( $ this -> _data , $ this -> _pos + 4 , $ length ) ; $ this -> _pos += 4 + $ length ; if ( ! $ this -> _readDataOnly ) { $ paperSize = self :: _GetInt2d ( $ recordData ... | Read PAGESETUP record |
12,478 | private function _readMulRk ( ) { $ length = self :: _GetInt2d ( $ this -> _data , $ this -> _pos + 2 ) ; $ recordData = $ this -> _readRecordData ( $ this -> _data , $ this -> _pos + 4 , $ length ) ; $ this -> _pos += 4 + $ length ; $ row = self :: _GetInt2d ( $ recordData , 0 ) ; $ colFirst = self :: _GetInt2d ( $ re... | Read MULRK record This record represents a cell range containing RK value cells . All cells are located in the same row . |
12,479 | private function _readBlank ( ) { $ length = self :: _GetInt2d ( $ this -> _data , $ this -> _pos + 2 ) ; $ recordData = $ this -> _readRecordData ( $ this -> _data , $ this -> _pos + 4 , $ length ) ; $ this -> _pos += 4 + $ length ; $ row = self :: _GetInt2d ( $ recordData , 0 ) ; $ col = self :: _GetInt2d ( $ recordD... | Read BLANK record |
12,480 | private function _readSelection ( ) { $ length = self :: _GetInt2d ( $ this -> _data , $ this -> _pos + 2 ) ; $ recordData = $ this -> _readRecordData ( $ this -> _data , $ this -> _pos + 4 , $ length ) ; $ this -> _pos += 4 + $ length ; if ( ! $ this -> _readDataOnly ) { $ paneId = ord ( $ recordData { 0 } ) ; $ r = s... | Read SELECTION record . There is one such record for each pane in the sheet . |
12,481 | private function _readRangeProtection ( ) { $ length = self :: _GetInt2d ( $ this -> _data , $ this -> _pos + 2 ) ; $ recordData = $ this -> _readRecordData ( $ this -> _data , $ this -> _pos + 4 , $ length ) ; $ this -> _pos += 4 + $ length ; $ offset = 0 ; if ( ! $ this -> _readDataOnly ) { $ offset += 12 ; $ isf = s... | Read RANGEPROTECTION record Reading of this record is based on Microsoft Office Excel 97 - 2000 Binary File Format Specification where it is referred to as FEAT record |
12,482 | private function _readContinue ( ) { $ length = self :: _GetInt2d ( $ this -> _data , $ this -> _pos + 2 ) ; $ recordData = $ this -> _readRecordData ( $ this -> _data , $ this -> _pos + 4 , $ length ) ; if ( $ this -> _drawingData == '' ) { $ this -> _pos += 4 + $ length ; return ; } if ( $ length < 4 ) { $ this -> _p... | Read a free CONTINUE record . Free CONTINUE record may be a camouflaged MSODRAWING record When MSODRAWING data on a sheet exceeds 8224 bytes CONTINUE records are used instead . Undocumented . In this case we must treat the CONTINUE record as a MSODRAWING record |
12,483 | public static function tag ( $ name , $ attributes = array ( ) , $ content = null ) { $ tag = '<' . $ name ; $ attributeString = static :: arrayToAttributes ( $ attributes ) ; if ( ! empty ( $ attributeString ) ) { $ tag .= ' ' . $ attributeString ; } if ( is_null ( $ content ) ) { $ tag .= '/>' ; } else { $ tag .= '>'... | Returns a HTML tag |
12,484 | public static function arrayToAttributes ( array $ attributes ) { $ attributeList = array ( ) ; foreach ( $ attributes as $ key => $ value ) { if ( $ value !== false ) { if ( is_string ( $ key ) ) { $ attributeList [ ] = htmlspecialchars ( $ key ) . '="' . htmlspecialchars ( $ value ) . '"' ; } else { $ attributeList [... | Produces a string of html tag attributes from an array |
12,485 | public function setHeader ( $ header ) { $ headers = [ ] ; if ( is_array ( $ header ) ) { foreach ( $ header as $ key => $ value ) { $ headers [ ] = $ key . ': ' . $ value ; } } else { $ headers [ ] = $ header ; } $ this -> setOpt ( CURLOPT_HTTPHEADER , $ headers ) ; return $ this ; } | Sets a header on the request |
12,486 | public static function from ( Date $ start , $ amount ) { return self :: cast ( DateTimeRange :: from ( new DateTime ( $ start ) , $ amount , new DateInterval ( 'P1D' ) ) ) ; } | Creates a DateRange object from the start date for the given amount of days . |
12,487 | public static function to ( Date $ end , $ amount ) { return self :: cast ( DateTimeRange :: to ( new DateTime ( $ end ) , $ amount , new DateInterval ( 'P1D' ) ) ) ; } | Creates a DateRange object to the end date for the given amount of days . |
12,488 | private static function cast ( DateTimeRange $ range ) { $ start = new Date ( $ range -> start ( ) ) ; $ end = new Date ( $ range -> end ( ) ) ; return new DateRange ( $ start , $ end ) ; } | Casts an DateTimeRange object into DateRange . |
12,489 | public function set ( $ key , $ value ) { if ( ! $ value instanceof Cell ) { throw new \ InvalidArgumentException ( 'Only Cells can be added to Rows' ) ; } parent :: set ( $ key , $ value ) ; } | Overrides the set method from DataContainer to ensure only Cells can be added |
12,490 | public function beforeSave ( Model $ model , $ options = array ( ) ) { $ settings = $ this -> settings [ $ model -> alias ] ; if ( empty ( $ model -> data [ $ model -> alias ] ) || empty ( $ model -> data [ $ model -> alias ] [ $ settings [ 'field' ] ] ) || ! empty ( $ model -> data [ $ model -> alias ] [ $ settings [ ... | Generate a slug based on another field . |
12,491 | public function slugExists ( Model $ model , $ slug ) { return ( bool ) $ model -> find ( 'count' , array ( 'conditions' => array ( $ this -> settings [ $ model -> alias ] [ 'slug' ] => $ slug ) , 'recursive' => - 1 , 'contain' => false ) ) ; } | Helper function to check if a slug exists . |
12,492 | public function add ( $ title , $ url , array $ options = array ( ) ) { $ this -> append ( $ title , $ url , $ options ) ; return $ this ; } | Add a breadcrumb to the list . |
12,493 | public function append ( $ title , $ url , array $ options = array ( ) ) { $ this -> _crumbs [ ] = array ( 'title' => strip_tags ( $ title ) , 'url' => $ url , 'options' => $ options ) ; $ this -> OpenGraph -> title ( $ this -> pageTitle ( null , array ( 'reverse' => true ) ) ) ; $ this -> OpenGraph -> uri ( $ url ) ; ... | Add a breadcrumb to the end of the list . |
12,494 | public function prepend ( $ title , $ url , array $ options = array ( ) ) { array_unshift ( $ this -> _crumbs , array ( 'title' => strip_tags ( $ title ) , 'url' => $ url , 'options' => $ options ) ) ; $ this -> OpenGraph -> title ( $ this -> pageTitle ( null , array ( 'reverse' => true ) ) ) ; $ this -> OpenGraph -> u... | Add a breadcrumb to the beginning of the list . |
12,495 | public function get ( $ key = '' ) { if ( ! $ key ) { return $ this -> _crumbs ; } $ crumbs = array ( ) ; foreach ( $ this -> _crumbs as $ crumb ) { $ crumbs [ ] = isset ( $ crumb [ $ key ] ) ? $ crumb [ $ key ] : null ; } return $ crumbs ; } | Return the list of breadcrumbs . |
12,496 | public function first ( $ key = '' ) { $ crumbs = $ this -> get ( $ key ) ; if ( ! $ crumbs ) { return null ; } $ first = array_slice ( $ crumbs , 0 , 1 ) ; return $ first [ 0 ] ; } | Return the first crumb in the list . |
12,497 | public function last ( $ key = '' ) { $ crumbs = $ this -> get ( $ key ) ; if ( ! $ crumbs ) { return null ; } $ last = array_slice ( $ crumbs , - 1 ) ; return $ last [ 0 ] ; } | Return the last crumb in the list . |
12,498 | public function pageTitle ( $ base = '' , array $ options = array ( ) ) { $ options = $ options + array ( 'reverse' => false , 'depth' => 3 , 'separator' => ' - ' ) ; $ crumbs = $ this -> get ( 'title' ) ; $ count = count ( $ crumbs ) ; $ title = array ( ) ; if ( $ count ) { if ( $ options [ 'depth' ] && $ count > $ op... | Generate a page title based off the current crumbs . |
12,499 | public function find ( $ type = 'first' , $ query = array ( ) ) { $ query = $ query + array ( 'fields' => array ( ) , 'order' => array ( 'date' => 'ASC' ) , 'limit' => 20 , 'feed' => array ( 'root' => '' , 'cache' => false , 'expires' => '+1 hour' ) ) ; return parent :: find ( $ type , $ query ) ; } | Overwrite the find method to be specific for feed aggregation . Set the default settings and prepare the URLs . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.