idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
59,300 | public function setAttachments ( $ attachments ) { foreach ( $ attachments as $ attachment ) { $ attachment -> setMail ( $ this ) ; } $ this -> setData ( 'attachments' , $ attachments ) ; return $ this ; } | Set reverse link on each attached entity |
59,301 | public function save ( ) { parent :: save ( ) ; $ this -> _storage -> saveMessage ( $ this ) ; $ this -> _storage -> saveAttachments ( $ this ) ; $ this -> _storage -> saveMail ( $ this ) ; } | Save mail to db message and attachments to storage |
59,302 | public function fire ( ) { $ context = Context :: guest ( ) ; $ this -> cmb -> set_context ( $ context ) ; $ this -> object_type = $ this -> cmb -> mb_object_type ( ) ; if ( $ this -> cmb -> prop ( 'hookup' ) ) { $ this -> universal_hooks ( ) ; } $ this -> once ( 'admin_footer' , [ __CLASS__ , 'enqueue_scripts' ] , 20 ... | Fire the hooks . |
59,303 | public function handleError ( $ event ) { $ event -> handled = true ; $ message = $ event -> message ; if ( YII_DEBUG ) { $ trace = debug_backtrace ( ) ; if ( isset ( $ trace [ 2 ] ) && isset ( $ trace [ 2 ] [ 'file' ] ) && isset ( $ trace [ 2 ] [ 'line' ] ) ) { $ message .= ' (' . $ trace [ 2 ] [ 'file' ] . ':' . $ tr... | The PHP error handler . |
59,304 | public function generateWsdl ( ) { if ( is_object ( $ this -> provider ) ) { $ providerClass = get_class ( $ this -> provider ) ; } else { $ providerClass = $ this -> provider ; } if ( $ this -> wsdlCacheDuration > 0 && $ this -> cacheID !== false && ( $ cache = Yii :: $ app -> get ( $ this -> cacheID , false ) ) !== n... | Generates the WSDL as defined by the provider . The cached version may be used if the WSDL is found valid in cache . |
59,305 | public static function sanitize_recursive ( $ values , $ sanitizer ) { if ( ! is_array ( $ values ) ) { return is_scalar ( $ values ) ? $ sanitizer ( $ values ) : $ values ; } foreach ( $ values as $ key => $ value ) { if ( is_array ( $ value ) ) { $ values [ $ key ] = static :: sanitize_recursive ( $ value , $ sanitiz... | Recursive sanitize a given values . |
59,306 | public static function esc_html_class ( $ classes ) { $ classes = array_filter ( array_unique ( ( array ) $ classes ) ) ; if ( empty ( $ classes ) ) { return '' ; } return implode ( ' ' , array_map ( 'sanitize_html_class' , $ classes ) ) ; } | Returns class string by given an array of classes . |
59,307 | private static function getBaseNamespace ( ) { $ composerFile = PSX_PATH_SRC . '/../composer.json' ; $ composer = \ json_decode ( \ file_get_contents ( $ composerFile ) , true ) ; if ( isset ( $ composer [ 'autoload' ] ) ) { $ paths = $ composer [ 'autoload' ] [ 'psr-4' ] ?? [ ] ; $ base = trim ( key ( $ paths ) , '\\'... | This method tries to find the base namespace of the current app . We try to look at the composer . json file and use the first psr - 4 autoload key |
59,308 | public static function getEngine ( & $ class ) { $ engine = null ; if ( ( $ pos = strpos ( $ class , '://' ) ) !== false ) { $ proto = substr ( $ class , 0 , $ pos ) ; switch ( $ proto ) { case 'file' : $ class = substr ( $ class , $ pos + 3 ) ; $ engine = self :: getEngineByFile ( $ class ) ; break ; case 'http' : cas... | This method determines the fitting engine for the provided string . The provided string gets modified in case it has the uri format |
59,309 | public function getArrayKeys ( ) { $ returnValue = [ ] ; foreach ( array_keys ( $ this -> getArrayCopy ( ) ) as $ key ) { if ( $ key != '_type' ) { $ returnValue [ ] = $ key ; } } return $ returnValue ; } | Gets key from current array . Excludes _type from final array . |
59,310 | private function getParts ( $ uri ) { return ( $ parsed = parse_url ( $ uri ) ) === false ? false : [ 'scheme' => isset ( $ parsed [ 'scheme' ] ) ? $ parsed [ 'scheme' ] . '://' : '' , 'host' => isset ( $ parsed [ 'host' ] ) ? $ parsed [ 'host' ] : $ parsed [ 'path' ] , 'port' => isset ( $ parsed [ 'port' ] ) ? ':' . $... | Get URI parts |
59,311 | public function htmlAttributes ( ) { if ( $ this -> direction ( ) === 'rtl' || $ this -> direction ( ) !== $ this -> script ( ) -> direction ( ) ) { return 'lang="' . $ this -> languageTag ( ) . '" dir="' . $ this -> direction ( ) . '"' ; } else { return 'lang="' . $ this -> languageTag ( ) . '"' ; } } | Markup for an HTML element |
59,312 | public function parse ( $ rules ) { if ( is_array ( $ rules ) ) { return $ this -> parse_array_rules ( $ rules ) ; } return $ this -> parse_string_rules ( $ rules ) ; } | Parse the rules into an array of rules . |
59,313 | public function normalize ( $ rule ) { $ rule = ucwords ( str_replace ( [ '-' , '_' ] , ' ' , $ rule ) ) ; $ rule = lcfirst ( str_replace ( ' ' , '' , $ rule ) ) ; switch ( $ rule ) { case 'creditcard' : return 'creditCard' ; case 'int' : return 'integer' ; case 'bool' : return 'boolean' ; default : return $ rule ; } } | Normalize a rule name . |
59,314 | protected function parse_string_rules ( $ rules ) { $ split_rules = explode ( '|' , $ rules ) ; $ parse_rules = [ ] ; foreach ( $ split_rules as $ rule ) { $ parameters = [ ] ; if ( strpos ( $ rule , ':' ) !== false ) { list ( $ rule , $ parameter ) = explode ( ':' , $ rule , 2 ) ; $ parameter = false !== strpos ( $ pa... | Parse a string based rules . |
59,315 | public function authenticateUser ( $ username , $ password , array $ status ) { if ( empty ( $ password ) ) { return null ; } if ( preg_match ( '/' . BackendSchema \ User :: NAME_PATTERN . '/' , $ username ) ) { $ column = 'name' ; } else { $ column = 'email' ; } $ condition = new Condition ( ) ; $ condition -> equals ... | Authenticates a user based on the username and password . Returns the user id if the authentication was successful else null |
59,316 | public function getDefaultScopes ( ) { $ scopes = $ this -> configService -> getValue ( 'scopes_default' ) ; return array_filter ( array_map ( 'trim' , Service \ Scope :: split ( $ scopes ) ) , function ( $ scope ) { return ! empty ( $ scope ) && $ scope != 'backend' ; } ) ; } | Returns the default scopes which every new user gets automatically assigned |
59,317 | protected function yearOrYearNo ( $ year ) { if ( is_scalar ( $ year ) ) { return $ this -> getYear ( $ year ) ; } if ( ! $ year instanceof Year ) { throw new InvalidArgumentException ( '$year must be an instance of BmCalendar\Year; got "' . get_class ( $ year ) . '"' ) ; } return $ year ; } | Checks the type of the provided parameter and returns the appropriate Year . |
59,318 | public function getMonth ( $ year , $ monthNo ) { $ year = $ this -> yearOrYearNo ( $ year ) ; return new Month ( $ year , $ monthNo ) ; } | Returns the appropriate Month object . |
59,319 | public function getMonths ( $ year ) { $ year = $ this -> yearOrYearNo ( $ year ) ; $ months = array ( ) ; for ( $ monthNo = 1 ; $ monthNo <= 12 ; $ monthNo ++ ) { $ months [ $ monthNo ] = new Month ( $ year , $ monthNo ) ; } return $ months ; } | Get this months for the given year . |
59,320 | public function getDay ( Month $ month , $ dayNo ) { $ dayNo = ( int ) $ dayNo ; if ( null === $ this -> dayProvider ) { return new Day ( $ month , $ dayNo ) ; } $ day = $ this -> dayProvider -> createDay ( $ month , $ dayNo ) ; if ( ! $ day instanceof DayInterface ) { throw new DomainException ( '$day must be instance... | Returns the requested day object . |
59,321 | public function getDays ( Month $ month ) { $ days = array ( ) ; for ( $ dayNo = 1 ; $ dayNo <= $ month -> numberOfDays ( ) ; $ dayNo ++ ) { $ days [ $ dayNo ] = $ this -> getDay ( $ month , $ dayNo ) ; } return $ days ; } | Returns all the days for the given month . |
59,322 | private function getPathFromUri ( $ uri ) { $ uriParser = new UriParser ( $ uri ) ; $ uriParser -> encode ( ) ; $ uri = $ uriParser -> stripFragment ( ) ; if ( strpos ( $ uri , '/' ) === 0 ) { return $ uri ; } if ( ! $ uriParser -> validate ( ) ) { throw new \ InvalidArgumentException ( 'Invalid URI' ) ; } $ path = ( (... | Get path and query |
59,323 | private function isBetween ( $ timestamp , $ fromTime , $ toTime , $ format = 'Hi' ) { $ dateTime = new DateTime ( ) ; $ timezone = new DateTimeZone ( 'UTC' ) ; $ dtRef = $ dateTime -> createFromFormat ( 'U' , $ timestamp , $ timezone ) ; $ dtFrom = $ dateTime -> createFromFormat ( $ format , $ fromTime , $ timezone ) ... | Is time between |
59,324 | private function checkPaths ( $ path , array $ paths ) { $ reserved = [ '?' => '\?' , '.' => '\.' , '*' => '.*' , '+' => '\+' , '(' => '\(' , ')' => '\)' , '[' => '\[' , ']' => '\]' , ] ; $ errorHandler = new ErrorHandler ( ) ; set_error_handler ( [ $ errorHandler , 'callback' ] , E_NOTICE | E_WARNING ) ; foreach ( $ p... | Check path rule |
59,325 | public function add_rule ( $ name , $ rules ) { $ parsed = ( new Validation_Parser ( ) ) -> parse ( $ rules ) ; foreach ( $ parsed as $ rule ) { $ this -> rule ( $ rule [ 0 ] , $ name , ... $ rule [ 1 ] ) ; } return $ this ; } | Add a single validation rule . |
59,326 | public function add_rules ( array $ rules ) { foreach ( $ rules as $ name => $ rule ) { $ this -> add_rule ( $ name , $ rule ) ; } return $ this ; } | Sets a multiple rules for the validation . |
59,327 | private function rmdir ( $ dir ) { $ files = scandir ( $ dir ) ; foreach ( $ files as $ file ) { if ( $ file == '.' || $ file == '..' ) { continue ; } $ path = $ dir . '/' . $ file ; if ( is_dir ( $ path ) ) { $ this -> rmdir ( $ path ) ; } elseif ( is_file ( $ path ) ) { unlink ( $ path ) ; } } rmdir ( $ dir ) ; } | Removes all files inside a directory recursively |
59,328 | protected function _initSelect ( ) { $ request = $ this -> _objectManager -> get ( 'Magento\Framework\App\RequestInterface' ) ; $ this -> getSelect ( ) -> from ( [ 'main_table' => $ this -> getMainTable ( ) ] ) ; if ( ! empty ( $ customerId = $ request -> getParam ( 'id' ) ) ) { $ this -> getSelect ( ) -> where ( 'cust... | Init collection select |
59,329 | public function isVisitTime ( $ timestamp = null ) { $ timestamp = is_int ( $ timestamp ) ? $ timestamp : time ( ) ; foreach ( $ this -> times as $ time ) { if ( $ this -> isBetween ( $ timestamp , $ time [ 'from' ] , $ time [ 'to' ] , 'Hi' ) ) { return true ; } } return empty ( $ this -> times ) ; } | Is visit - time |
59,330 | public function hasSchema ( $ schemaId ) { $ sql = ' SELECT COUNT(resp.id) AS cnt FROM fusio_routes_response resp INNER JOIN fusio_routes_method method ON resp.method_id = method.id INNER JOIN fusio_routes routes ON rout... | Returns whether a schema id is in use by a route . In the worst case this gets reported by the database constraints but we use this method to report a proper error message |
59,331 | public function hasAction ( $ actionId ) { $ sql = ' SELECT COUNT(method.id) AS cnt FROM fusio_routes_method method INNER JOIN fusio_routes routes ON routes.id = method.route_id WHERE routes.status = 1 AND method.act... | Returns whether a action id is in use by a route . In the worst case this gets reported by the database constraints but we use this method to report a proper error message |
59,332 | public function getMethods ( $ routeId , $ version = null , $ active = true , $ cache = false ) { $ fields = [ 'method.id' , 'method.route_id' , 'method.version' , 'method.status' , 'method.method' , 'method.active' , 'method.public' , 'method.description' , 'method.parameters' , 'method.request' , 'method.action' , 'm... | Returns only active methods for the route |
59,333 | public function detectWithCommon ( $ uri , array $ customParam = [ ] ) { $ pairs = array_merge_recursive ( $ this -> cleanParam , $ this -> appendPath ( $ this -> commonParam ) , $ this -> appendPath ( $ customParam ) ) ; return $ this -> parse ( $ uri , $ pairs ) ; } | Has robots . txt defined dynamic or common dynamic parameters check |
59,334 | protected function parse ( $ uri , array $ pairs ) { $ path = $ this -> getPathFromUri ( $ uri ) ; $ result = [ ] ; foreach ( $ pairs as $ param => $ paths ) { if ( ( strpos ( $ uri , "?$param=" ) || strpos ( $ uri , "&$param=" ) ) && $ this -> checkPaths ( $ path , $ paths ) !== false ) { $ result [ ] = $ param ; } } ... | Parse uri and return detected parameters |
59,335 | public function nextUpdate ( ) { if ( $ this -> rawStatusCode === 503 && strpos ( $ this -> base , 'http' ) === 0 ) { return $ this -> time + min ( self :: CACHE_TIME , $ this -> headerParser -> getRetryAfter ( $ this -> time ) ) ; } return $ this -> time + self :: CACHE_TIME ; } | Next update timestamp |
59,336 | private function generate ( $ level , $ eol ) { $ handler = new RenderHandler ( $ level , $ eol ) ; if ( $ level == 2 ) { $ this -> root -> userAgent -> render ( $ handler ) ; } $ this -> root -> host -> render ( $ handler ) ; $ this -> root -> cleanParam -> render ( $ handler ) ; $ this -> root -> sitemap -> render ( ... | Generate an rule string array |
59,337 | protected function getWsdlElementAttributes ( $ comment ) { $ nillable = $ minOccurs = $ maxOccurs = null ; if ( preg_match ( '/{(.+)}/' , $ comment , $ attr ) ) { if ( preg_match_all ( '/((\w+)\s*=\s*(\w+))/mi' , $ attr [ 1 ] , $ attr ) ) { foreach ( $ attr [ 2 ] as $ id => $ prop ) { $ prop = strtolower ( $ prop ) ; ... | Parse attributes nillable minOccurs maxOccurs |
59,338 | protected function injectDom ( \ DOMDocument $ dom , \ DOMElement $ target , \ DOMNode $ source ) { if ( $ source -> nodeType != XML_ELEMENT_NODE ) { return ; } $ import = $ dom -> createElement ( $ source -> nodeName ) ; foreach ( $ source -> attributes as $ attr ) { $ import -> setAttribute ( $ attr -> name , $ attr ... | Import custom XML source node into WSDL document under specified target node |
59,339 | private function getRequirements ( string $ docComment ) : array { return array_map ( function ( $ tag ) { preg_match ( '#@require ([^ ]*)#' , $ tag , $ match ) ; return $ match [ 1 ] ; } , array_filter ( array_map ( 'trim' , explode ( "\n" , str_replace ( "\r\n" , "\n" , $ docComment ) ) ) , function ( $ docline ) { r... | Get required interfaces |
59,340 | protected function initFilters ( ) { if ( ! empty ( $ this -> filters ) ) { foreach ( $ this -> filters as $ name => $ handler ) { $ this -> addFilter ( $ name , $ handler ) ; } } } | Add custom filters from ViewRenderer filters parameter . |
59,341 | protected function initCachePath ( ) { $ cachePath = empty ( $ this -> cachePath ) ? false : Yii :: getAlias ( $ this -> cachePath ) ; if ( ! empty ( $ cachePath ) && ! file_exists ( $ cachePath ) ) { FileHelper :: createDirectory ( $ cachePath ) ; } return $ cachePath ; } | Create if needed and return the cache path calculated from ViewRenderer cachePath parameter . |
59,342 | public function init ( ) { $ cachePath = $ this -> initCachePath ( ) ; if ( ! empty ( $ cachePath ) && ! is_readable ( $ cachePath ) ) { throw new Exception ( Yii :: t ( 'app' , 'Pug cache path is not readable.' ) ) ; } if ( ! empty ( $ cachePath ) && ! is_writable ( $ cachePath ) ) { throw new Exception ( Yii :: t ( '... | Create the pug renderer engine . |
59,343 | public function addFilter ( $ name , $ handler ) { if ( is_string ( $ handler ) && ! is_callable ( $ handler ) ) { $ handler = new $ handler ( ) ; } $ this -> pug -> filter ( $ name , $ handler ) ; } | Adds custom filter . |
59,344 | public function getStyle ( ) { $ style = '' ; $ height = $ this -> FixedHeight ; if ( ! $ height ) { $ height = 800 ; } $ style .= "height: {$height}px; " ; if ( $ this -> AutoWidth ) { $ style .= "width: 100%; " ; } elseif ( $ this -> FixedWidth ) { $ style .= "width: {$this->FixedWidth}px; " ; } return $ style ; } | Compute style from the size parameters . |
59,345 | public function validate ( ) { $ result = parent :: validate ( ) ; $ allowed_schemes = array ( 'http' , 'https' ) ; if ( $ matches = parse_url ( $ this -> IFrameURL ) ) { if ( isset ( $ matches [ 'scheme' ] ) && ! in_array ( $ matches [ 'scheme' ] , $ allowed_schemes ) ) { $ result -> addError ( _t ( __CLASS__ . '.VALI... | Ensure that the IFrameURL is a valid url and prevents XSS |
59,346 | public function setFrom ( $ from ) { $ result = $ this -> _senderResolver -> resolve ( $ from , $ this -> getStoreId ( ) ) ; $ this -> setSenderMail ( $ result ) ; $ this -> message -> setFrom ( $ result [ 'email' ] , $ result [ 'name' ] ) ; return $ this ; } | Set mail from address |
59,347 | public function get_field_in_group ( $ field_group , $ sub_field ) { if ( ! $ field_group instanceof Field_Contract ) { $ field_group = $ this -> get_field ( $ field_group ) ; } if ( ! $ field_group || 'group' !== $ field_group -> get_type ( ) ) { return null ; } $ sub_fields = $ field_group -> prop ( 'fields' , [ ] ) ... | Gets a field in a group . |
59,348 | public function get_field_raw ( $ field ) { if ( array_key_exists ( $ field , $ this -> prop ( 'fields' ) ) ) { return $ this -> prop ( 'fields' ) [ $ field ] ; } return null ; } | Return the field raw |
59,349 | public function get ( $ type ) { if ( $ type === self :: TYPE_MAILER ) { $ name = $ this -> configService -> getValue ( 'system_mailer' ) ; } elseif ( $ type === self :: TYPE_DISPATCHER ) { $ name = $ this -> configService -> getValue ( 'system_dispatcher' ) ; } else { throw new \ InvalidArgumentException ( 'Provided t... | Returns a configured connection from the provided type |
59,350 | protected function initSources ( array $ sources ) { foreach ( $ sources as $ source ) { $ this -> sources [ ] = new EntitySource ( $ this , $ source ) ; } } | Populate the sources array . |
59,351 | public static function getAggregator ( $ id ) { assert ( 'is_string($id)' ) ; $ config = Configuration :: getConfig ( 'module_aggregator2.php' ) ; return new Aggregator ( $ id , $ config -> getConfigItem ( $ id ) ) ; } | Return an instance of the aggregator with the given id . |
59,352 | public function isCacheValid ( $ id , $ tag = null ) { assert ( 'is_string($id)' ) ; assert ( 'is_null($tag) || is_string($tag)' ) ; $ cacheFile = strval ( $ this -> cacheDirectory ) . '/' . $ id ; if ( ! file_exists ( $ cacheFile ) ) { return false ; } $ expireFile = $ cacheFile . '.expire' ; if ( ! file_exists ( $ ex... | Check validity of cached data . |
59,353 | public function getCacheItem ( $ id , $ tag = null ) { assert ( 'is_string($id)' ) ; assert ( 'is_null($tag) || is_string($tag)' ) ; if ( ! $ this -> isCacheValid ( $ id , $ tag ) ) { return null ; } $ cacheFile = strval ( $ this -> cacheDirectory ) . '/' . $ id ; return @ file_get_contents ( $ cacheFile ) ; } | Get the cache item . |
59,354 | public function getCacheFile ( $ id ) { assert ( 'is_string($id)' ) ; $ cacheFile = strval ( $ this -> cacheDirectory ) . '/' . $ id ; if ( ! file_exists ( $ cacheFile ) ) { return null ; } return $ cacheFile ; } | Get the cache filename for the specific id . |
59,355 | protected function addSignature ( SignedElement $ element ) { if ( $ this -> signKey === null ) { return ; } $ privateKey = new XMLSecurityKey ( $ this -> signAlg , [ 'type' => 'private' ] ) ; if ( $ this -> signKeyPass !== null ) { $ privateKey -> passphrase = $ this -> signKeyPass ; } $ privateKey -> loadKey ( $ this... | Sign the generated EntitiesDescriptor . |
59,356 | private static function extractEntityDescriptors ( EntitiesDescriptor $ entity ) { $ results = [ ] ; foreach ( $ entity -> children as $ child ) { if ( $ child instanceof EntityDescriptor ) { $ results [ ] = $ child ; continue ; } $ results = array_merge ( $ results , self :: extractEntityDescriptors ( $ child ) ) ; } ... | Recursively browse the children of an EntitiesDescriptor element looking for EntityDescriptor elements and return an array containing all of them . |
59,357 | protected function getEntitiesDescriptor ( ) { $ ret = new EntitiesDescriptor ( ) ; $ now = time ( ) ; if ( ! empty ( $ this -> regInfo ) ) { $ ri = new RegistrationInfo ( ) ; $ ri -> registrationInstant = $ now ; foreach ( $ this -> regInfo as $ riName => $ riValues ) { switch ( $ riName ) { case 'authority' : $ ri ->... | Retrieve all entities as an EntitiesDescriptor . |
59,358 | public function excludeEntities ( $ entities ) { assert ( 'is_array($entities) || is_null($entities)' ) ; if ( $ entities === null ) { return ; } $ this -> excluded = $ entities ; sort ( $ this -> excluded ) ; $ this -> cacheId = sha1 ( $ this -> cacheId . serialize ( $ this -> excluded ) ) ; } | Set this aggregator to exclude a set of entities from the resulting aggregate . |
59,359 | private function lineBreak ( ) { if ( $ this -> previousRoot !== $ this -> directive && in_array ( $ this -> directive , array_keys ( RobotsTxtParser :: TOP_LEVEL_DIRECTIVES ) ) || $ this -> previous !== self :: DIRECTIVE_USER_AGENT && $ this -> directive === self :: DIRECTIVE_USER_AGENT ) { $ this -> previousRoot = $ ... | Returns an line separator if required |
59,360 | public function getConfig ( ) { if ( $ this -> config ) { return $ this -> config ; } $ config = $ this -> getDefaultConfig ( ) ; $ result = $ this -> connection -> fetchAll ( 'SELECT type, class FROM fusio_provider ORDER BY class ASC' ) ; foreach ( $ result as $ row ) { $ this -> mergeClass ( $ config , $ row [ 'type'... | Returns the provider config of the system |
59,361 | public function save ( $ selection = null ) { if ( func_num_args ( ) ) { if ( is_array ( $ selection ) ) { $ filter = array ( ) ; foreach ( $ this -> container as $ file ) { $ match = true ; foreach ( $ selection as $ item => $ value ) { if ( $ value != $ file -> { $ item } ) { $ match = false ; break ; } } $ match and... | Runs save on all loaded file objects |
59,362 | public function isValid ( ) { foreach ( $ this -> container as $ file ) { if ( ! $ file -> isValid ( ) ) { return false ; } } return empty ( $ this -> container ) ? false : true ; } | Returns a consolidated status of all uploaded files |
59,363 | public function getAllFiles ( $ index = null ) { if ( $ selection = ( func_num_args ( ) and ! is_null ( $ index ) ) ? $ this [ $ index ] : $ this -> container ) { is_array ( $ selection ) or $ selection = array ( $ selection ) ; } else { $ selection = array ( ) ; } return $ selection ; } | Returns the list of uploaded files |
59,364 | public function getValidFiles ( $ index = null ) { if ( is_numeric ( $ index ) ) { $ selection = $ this -> container ; } else { $ selection = ( func_num_args ( ) and ! is_null ( $ index ) ) ? $ this [ $ index ] : $ this -> container ; } $ results = array ( ) ; if ( $ selection ) { is_array ( $ selection ) or $ selectio... | Returns the list of uploaded files that valid |
59,365 | public function register ( $ event , $ callback ) { if ( ! isset ( $ this -> callbacks [ $ event ] ) ) { throw new \ InvalidArgumentException ( $ event . ' is not a valid event' ) ; } if ( ! is_callable ( $ callback ) ) { throw new \ InvalidArgumentException ( 'Callback passed is not callable' ) ; } $ this -> callbacks... | Registers a callback for a given event |
59,366 | protected function addFile ( array $ entry ) { $ this -> container [ ] = new File ( $ entry , $ this -> callbacks ) ; end ( $ this -> container ) -> setConfig ( $ this -> defaults ) ; } | Adds a new uploaded file structure to the container |
59,367 | public function loadMail ( $ id ) { try { return $ this -> _storage -> loadMail ( $ id ) ; } catch ( \ Exception $ e ) { throw new MailException ( new Phrase ( $ e -> getMessage ( ) ) , $ e ) ; } } | Use the concrete storage implementation to load the mail to storage |
59,368 | public function jsonSerialize ( ) { $ data = $ this -> getData ( ) ; $ data [ 'binary' ] = '' ; $ data [ 'mail' ] = $ this -> getMail ( ) -> getId ( ) ; return $ data ; } | Return all data except binary |
59,369 | public function toMimePart ( ) { $ attachmentMimePart = new Zend_Mime_Part ( $ this -> getBinary ( ) ) ; $ attachmentMimePart -> type = $ this -> getMimeType ( ) ; $ attachmentMimePart -> disposition = $ this -> getDisposition ( ) ; $ attachmentMimePart -> encoding = $ this -> getEncoding ( ) ; $ attachmentMimePart -> ... | Returns a mime part converted attachment |
59,370 | public function getBinary ( ) { if ( empty ( $ this -> getData ( 'binary' ) ) ) { $ attachmentBinary = file_get_contents ( $ this -> getFilePath ( ) ) ; $ this -> setData ( 'binary' , $ attachmentBinary ) ; } return $ this -> getData ( 'binary' ) ; } | Returns binary data of a single attachment file |
59,371 | public function getDisposition ( ) { if ( empty ( $ this -> getData ( 'disposition' ) ) ) { $ this -> setData ( 'disposition' , Zend_Mime :: DISPOSITION_ATTACHMENT ) ; } return $ this -> getData ( 'disposition' ) ; } | Returns current setting of how to integrate attachment into message |
59,372 | public function active ( ) { $ show = true ; if ( is_callable ( $ this -> active_callback ) ) { $ show = call_user_func ( $ this -> active_callback , $ this ) ; } return $ show ; } | Check whether section is active to current screen . |
59,373 | public function check_capabilities ( ) { if ( $ this -> capability && ! call_user_func_array ( 'current_user_can' , ( array ) $ this -> capability ) ) { return false ; } if ( $ this -> theme_supports && ! call_user_func_array ( 'current_theme_supports' , ( array ) $ this -> theme_supports ) ) { return false ; } return ... | Checks required user capabilities and whether the theme has the feature support required by the section . |
59,374 | public function buildZip ( $ file , $ basePath ) { yield 'Generating zip file ' . $ file ; $ zip = new \ ZipArchive ( ) ; $ res = $ zip -> open ( $ file , \ ZipArchive :: CREATE ) ; if ( $ res === true ) { $ this -> buildZipArchive ( $ basePath , $ zip , $ basePath , 0 ) ; $ zip -> close ( ) ; yield 'Generation complet... | Creates a zip archive for the provided file using all files located at the base path |
59,375 | public static function check ( array $ fields , array $ data ) { $ dependency = new static ( $ data ) ; foreach ( $ fields as $ field ) { if ( ! $ field -> get_option ( 'deps' ) ) { continue ; } $ satisfied = $ dependency -> apply ( $ deps = $ field -> get_option ( 'deps' ) ) ; $ field -> set_option ( 'row_attributes' ... | Check the fields dependencies . |
59,376 | public function apply ( $ rules ) { $ satisfied = true ; if ( empty ( $ rules ) || ! is_array ( $ rules ) ) { return $ satisfied ; } if ( ! is_null ( $ rule = $ this -> get_rule ( $ rules ) ) ) { return $ rule -> apply ( $ this -> data ) ; } return $ satisfied ; } | Check rules is satisfied the conditions . |
59,377 | public function get_rule ( array $ rules ) { $ logical = static :: LOGICAL_AND ; if ( static :: is_group_rules ( $ rules ) ) { list ( $ logical , $ rules ) = $ this -> parse_group_logical ( $ rules ) ; } return $ this -> create_rule ( $ rules , $ logical ) ; } | Gets the rule . |
59,378 | public function create_rule ( array $ rules , $ logical = 'and' ) { if ( empty ( $ rules ) ) { return null ; } if ( static :: is_proposition ( $ rules ) ) { $ rules = [ $ rules ] ; } if ( ! $ props = $ this -> build_propositions ( $ rules ) ) { return null ; } if ( static :: LOGICAL_OR === $ logical && count ( $ props ... | Create new rule based on an array of rules . |
59,379 | protected function build_propositions ( array $ rules ) { $ props = [ ] ; foreach ( $ rules as $ rule ) { if ( ! is_array ( $ rule ) || ! static :: is_proposition ( $ rule ) ) { continue ; } try { $ props [ ] = $ this -> create_proposition ( ... $ rule ) ; } catch ( \ Exception $ e ) { continue ; } } return array_filte... | Build propositions based given array rules . |
59,380 | protected function create_proposition ( $ parent_name , $ operator = null , $ check_value = null ) { list ( $ operator , $ check_value ) = $ this -> normalize_proposition ( $ operator , $ check_value ) ; if ( is_string ( $ check_value ) && 0 === strpos ( $ check_value , '@' ) ) { $ check_value = $ this -> new_variable ... | Create a rule proposition . |
59,381 | protected function normalize_proposition ( $ operator = null , $ check_value = null ) { if ( is_null ( $ check_value ) && 0 !== strpos ( $ operator , 'is_' ) ) { list ( $ check_value , $ operator ) = [ $ operator , '=' ] ; } $ operator = $ this -> normalize_operator ( $ operator ) ; if ( ! in_array ( $ operator , stati... | Normalize the proposition . |
59,382 | private function getRatio ( $ rate , $ time ) { $ gcd = $ this -> getGCD ( $ rate , $ time ) ; $ requests = $ rate / $ gcd ; $ time = $ time / $ gcd ; $ suffix = 's' ; foreach ( $ this -> units as $ unit => $ sec ) { if ( $ time % $ sec === 0 ) { $ suffix = $ unit ; $ time /= $ sec ; break ; } } return $ requests . '/'... | Get ratio string |
59,383 | private function getGCD ( $ a , $ b ) { if ( extension_loaded ( 'gmp' ) ) { return gmp_intval ( gmp_gcd ( ( string ) $ a , ( string ) $ b ) ) ; } $ large = $ a > $ b ? $ a : $ b ; $ small = $ a > $ b ? $ b : $ a ; $ remainder = $ large % $ small ; return 0 === $ remainder ? $ small : $ this -> getGCD ( $ small , $ rema... | Returns the greatest common divisor of two integers using the Euclidean algorithm . |
59,384 | public function setStartDay ( $ startDay ) { $ startDay = ( int ) $ startDay ; if ( $ startDay < 1 || $ startDay > 7 ) { throw new OutOfRangeException ( "'$startDay' is an invalid value for \$startDay in '" . __METHOD__ ) ; } $ this -> startDay = $ startDay ; return $ this ; } | Set which day to display as the starting day of the week . |
59,385 | public function showMonth ( $ year , $ month ) { if ( null !== $ this -> partial ) { $ partial = $ this -> view -> plugin ( 'partial' ) ; $ params = array ( 'calendar' => $ this -> calendar , 'startDay' => $ this -> startDay , 'year' => $ year , 'month' => $ month , ) ; return $ partial ( $ this -> partial , $ params )... | Returns the HTML to display a month . |
59,386 | public function isLeap ( ) { if ( 0 !== $ this -> year % 4 ) { return false ; } if ( 0 !== $ this -> year % 100 ) { return true ; } if ( 0 !== $ this -> year % 400 ) { return false ; } return true ; } | Checks if this year is a leap year . |
59,387 | public function getDocumentation ( $ version = null ) { return $ this -> routesMethodService -> getDocumentation ( $ this -> context -> getRouteId ( ) , $ version , $ this -> context -> getPath ( ) ) ; } | Select all methods from the routes method table and build a resource based on the data . If the route is in production mode read the schema from the cache else resolve it |
59,388 | private function getHostname ( ) { $ host = parse_url ( $ this -> config -> get ( 'psx_url' ) , PHP_URL_HOST ) ; if ( empty ( $ host ) ) { $ host = $ _SERVER [ 'SERVER_NAME' ] ; } return $ host ; } | Tries to determine the current hostname |
59,389 | private function handlerAdd ( $ group ) { if ( ! in_array ( $ group , array_keys ( $ this -> handler ) ) ) { $ this -> handler [ $ group ] = new SubDirectiveHandler ( $ this -> base , $ group ) ; return true ; } return false ; } | Add sub - directive handler |
59,390 | protected function normalize ( ) { $ this -> container [ 'filename' ] = html_entity_decode ( $ this -> container [ 'filename' ] , ENT_QUOTES , 'UTF-8' ) ; $ this -> container [ 'filename' ] = preg_replace ( "#[\"\']#" , '' , $ this -> container [ 'filename' ] ) ; $ this -> container [ 'filename' ] = preg_replace ( "#[^... | Converts a filename into a normalized name . only outputs 7 bit ASCII characters . |
59,391 | protected function addError ( $ error ) { $ this -> errors [ ] = new FileError ( $ error , $ this -> config [ 'langCallback' ] ) ; $ this -> isValid = false ; } | Adds a new error object to the list |
59,392 | public static function initialize ( ) { foreach ( static :: $ core_types as $ name => $ class ) { static :: register ( $ name , new $ class ) ; } foreach ( static :: $ bindings as $ name => $ binding ) { if ( ! static :: resolved ( $ name ) ) { static :: fire ( $ name , $ binding [ 'callback' ] , $ binding [ 'sanitizer... | Initialize the custom fields . |
59,393 | public static function register ( $ name , $ callback = null , $ sanitizer = null ) { unset ( static :: $ resolved [ $ name ] ) ; if ( $ callback instanceof Field_Type ) { $ instance = $ callback ; list ( $ callback , $ sanitizer ) = [ [ $ instance , 'display' ] , [ $ instance , 'sanitization' ] , ] ; static :: $ insta... | Register a custom field type . |
59,394 | public static function fire ( $ name , callable $ callback , $ sanitizer = null ) { add_action ( "cmb2_render_{$name}" , static :: get_render_callback ( $ callback ) , 10 , 5 ) ; if ( ! is_null ( $ sanitizer ) && is_callable ( $ sanitizer ) ) { add_filter ( "cmb2_sanitize_{$name}" , static :: get_sanitize_callback ( $ ... | Fire the hooks to add field type in to the CMB2 . |
59,395 | public static function print_js_templates ( ) { foreach ( static :: $ instances as $ type => $ control ) { if ( ! method_exists ( $ control , 'template' ) ) { continue ; } ?> <script type="text/html" id="tmpl-wplibs-field- <?php echo esc_attr ( $ type ) ; ?> -content"> <?php $ control -> template ( ) ; ?> </script>... | Print the field JS templates . |
59,396 | protected static function get_render_callback ( $ callback ) { return function ( $ field , $ escaped_value , $ object_id , $ object_type , $ field_types ) use ( $ callback ) { if ( $ field instanceof Contracts \ Field ) { $ callback ( $ field , $ escaped_value , $ field_types ) ; } } ; } | Get the render field callback . |
59,397 | protected static function get_sanitize_callback ( $ sanitize_cb ) { return function ( $ check , $ value , $ object_id , $ field_args , $ sanitizer ) use ( $ sanitize_cb ) { if ( $ field_args [ 'repeatable' ] ) { return Utils :: filter_blank ( is_array ( $ value ) ? array_map ( $ sanitize_cb , $ value ) : [ ] ) ; } retu... | Get the sanitize callback . |
59,398 | public static function syncConfig ( Connection $ connection , array $ configs , \ Closure $ callback ) { foreach ( $ configs as $ row ) { $ config = $ connection -> fetchAssoc ( 'SELECT id, name FROM fusio_config WHERE name = :name' , [ 'name' => $ row [ 'name' ] ] ) ; if ( empty ( $ config ) ) { self :: insertRow ( 'f... | Helper method to sync all config values of an existing system |
59,399 | public static function syncRoutes ( Connection $ connection , array $ routes , \ Closure $ callback ) { $ scopes = [ ] ; $ maxId = ( int ) $ connection -> fetchColumn ( 'SELECT MAX(id) AS max_id FROM fusio_routes' ) ; foreach ( $ routes as $ row ) { $ route = $ connection -> fetchAssoc ( 'SELECT id, status, priority, m... | Helper method to sync all routes of an existing system |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.