idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
7,900
public function html2text ( $ html , $ advanced = false ) { if ( $ advanced ) { require_once 'extras/class.html2text.php' ; $ htmlconverter = new html2text ( $ html ) ; return $ htmlconverter -> get_text ( ) ; } return html_entity_decode ( trim ( strip_tags ( preg_replace ( '/<(head|title|style|script)[^>]*>.*?<\/\\1>/...
Convert an HTML string into plain text .
7,901
public static function _mime_types ( $ ext = '' ) { $ mimes = array ( 'xl' => 'application/excel' , 'hqx' => 'application/mac-binhex40' , 'cpt' => 'application/mac-compactpro' , 'bin' => 'application/macbinary' , 'doc' => 'application/msword' , 'word' => 'application/msword' , 'class' => 'application/octet-stream' , 'd...
Get the MIME type for a file extension .
7,902
public function set ( $ name , $ value = '' ) { try { if ( isset ( $ this -> $ name ) ) { $ this -> $ name = $ value ; } else { throw new phpmailerException ( $ this -> lang ( 'variable_set' ) . $ name , self :: STOP_CRITICAL ) ; } } catch ( Exception $ exc ) { $ this -> setError ( $ exc -> getMessage ( ) ) ; if ( $ ex...
Set or reset instance properties .
7,903
public static function runtime ( $ fnc = null , $ params = array ( ) ) { if ( is_null ( $ fnc ) ) { return static :: $ runtime_class ; } return call_user_func_array ( array ( static :: $ runtime_class , $ fnc ) , $ params ) ; }
get the current runtime class name or execute an function on the runtime class
7,904
public static function paths ( $ paths = null , $ define = true ) { if ( is_null ( $ paths ) ) { return static :: $ paths ; } foreach ( $ paths as $ key => $ path ) { static :: $ paths [ $ key ] = $ path ; if ( $ define === true ) { define ( strtoupper ( $ key ) . 'PATH' , $ path ) ; } } }
paths getter and setter
7,905
public static function directories ( $ dirs = null , $ define = true ) { if ( is_null ( $ dirs ) ) { return static :: $ directories ; } foreach ( $ dirs as $ key => $ dir ) { static :: $ directories [ $ key ] = $ dir ; if ( $ define === true ) { define ( 'CCDIR_' . strtoupper ( $ key ) , $ dir ) ; } } }
directories getter and setter
7,906
public static function wake ( $ environment ) { if ( ! is_null ( static :: $ environment ) ) { throw new CCException ( "ClanCats::wake - you cannot wake the application twice." ) ; } static :: $ environment = $ environment ; static :: $ config = CCConfig :: create ( 'main' ) ; CCError_Inspector :: info_callback ( 'Clan...
start the ccf lifecycle
7,907
public static function wake_app ( $ app ) { static :: $ runtime_class = $ app ; \ CCFinder :: bind ( $ app , static :: $ paths [ 'app' ] . $ app . EXT ) ; $ response = $ app :: wake ( ) ; if ( $ response instanceof CCResponse ) { if ( static :: $ config -> send_app_wake_response ) { $ response -> send ( true ) ; die ; ...
start the ccf app lifecycle
7,908
public function join ( Builder $ objBuilder , $ blnExpandSelection = false , iCondition $ objJoinCondition = null , Clause \ Select $ objSelect = null ) { $ objParentNode = $ this -> objParentNode ; if ( ! $ objParentNode ) { throw new Caller ( 'A column node must have a parent node.' ) ; } else { $ objParentNode -> jo...
Join the node to the given query . Since this is a leaf node we pass on the join to the parent .
7,909
public function getAsManualSqlColumn ( ) { if ( $ this -> strTableName ) { return $ this -> strTableName . '.' . $ this -> strName ; } else { if ( ( $ this -> objParentNode ) && ( $ this -> objParentNode -> strTableName ) ) { return $ this -> objParentNode -> strTableName . '.' . $ this -> strName ; } else { return $ t...
Get the unaliased column name . For special situations like order by since you can t order by aliases .
7,910
public function getUserRolePermissions ( ) { $ roles = Role :: select ( 'id' , 'name' , 'label' ) -> get ( ) ; $ permissions = Permission :: select ( 'id' , 'name' , 'label' ) -> get ( ) ; return \ View :: make ( 'admin.permissions.role-assign-permissions' , [ 'roles' => $ roles , 'permissions' => $ permissions , 'titl...
Display given permissions to role .
7,911
public function postUserRolePermissions ( Request $ request ) { $ this -> validate ( $ request , [ 'role' => 'required' , 'permissions' => 'required' ] ) ; $ role = Role :: with ( 'permissions' ) -> whereName ( $ request -> role ) -> first ( ) ; $ role -> permissions ( ) -> detach ( ) ; foreach ( $ request -> permissio...
Store given permissions to role .
7,912
public static function create ( $ paths , $ cache = null , $ debug = false ) { $ wise = new self ( $ debug ) ; if ( $ cache ) { $ wise -> setCacheDir ( $ cache ) ; } $ locator = new FileLocator ( $ paths ) ; $ resolver = new LoaderResolver ( array ( new Loader \ IniFileLoader ( $ locator ) , new Loader \ JsonFileLoader...
Creates a pre - configured instance of Wise .
7,913
public function load ( $ resource , $ type = null , $ require = false ) { if ( null === $ this -> loader ) { throw new LogicException ( 'No loader has been configured.' ) ; } if ( false === $ this -> loader -> supports ( $ resource , $ type ) ) { throw LoaderException :: format ( 'The resource "%s"%s is not supported b...
Loads the configuration data from a resource .
7,914
public function loadFlat ( $ resource , $ type = null , $ require = false ) { return ArrayUtil :: flatten ( $ this -> load ( $ resource , $ type , $ require ) ) ; }
Loads the configuration data from a resource and returns it flattened .
7,915
public function setCollector ( ResourceCollectorInterface $ collector ) { $ this -> collector = $ collector ; if ( $ this -> loader ) { if ( $ this -> loader instanceof ResourceAwareInterface ) { $ this -> loader -> setResourceCollector ( $ collector ) ; } if ( $ this -> loader instanceof DelegatingLoader ) { $ resolve...
Sets the resource collector .
7,916
public function setGlobalParameters ( $ parameters ) { if ( ! is_array ( $ parameters ) && ! ( $ parameters instanceof ArrayAccess ) ) { throw new InvalidArgumentException ( 'The $parameters argument must be an array or array accessible object.' ) ; } $ this -> parameters = $ parameters ; }
Sets a list of global parameters .
7,917
public function setLoader ( LoaderInterface $ loader ) { $ this -> loader = $ loader ; if ( $ this -> collector && ( $ loader instanceof ResourceAwareInterface ) ) { $ loader -> setResourceCollector ( $ this -> collector ) ; } if ( $ loader instanceof WiseAwareInterface ) { $ loader -> setWise ( $ this ) ; } if ( $ loa...
Sets a configuration loader .
7,918
private function process ( array $ data , $ resource , $ type , $ require ) { if ( $ this -> processor ) { if ( $ this -> processor instanceof ProcessorInterface ) { if ( $ this -> processor -> supports ( $ resource , $ type ) ) { $ data = $ this -> processor -> process ( $ data ) ; } elseif ( $ require ) { throw Proce...
Processes the configuration definition .
7,919
public static function create ( $ path ) { if ( is_null ( $ path ) ) { return new static ( ) ; } if ( substr ( $ path , 0 , 1 ) != '/' ) { $ path = ORBITPATH . $ path ; } if ( substr ( $ path , - 1 ) != '/' ) { $ path .= '/' ; } $ blueprint = $ path . 'blueprint.json' ; if ( ! file_exists ( $ blueprint ) ) { throw new ...
create an new ship object from path
7,920
public static function blueprint ( $ data , $ path ) { if ( ! is_array ( $ data ) ) { throw new \ InvalidArgumentException ( "CCOrbit_Ship::blueprint - first argument has to be an array." ) ; } $ ship = new static ( ) ; $ name = $ data [ 'name' ] ; $ namespace = $ data [ 'namespace' ] ; if ( is_null ( $ name ) ) { $ na...
create new ship with given data
7,921
public function event ( $ event ) { if ( is_string ( $ this -> namespace ) ) { if ( strpos ( $ event , '::' ) !== false ) { $ callback = explode ( '::' , $ event ) ; $ class = $ this -> namespace . "\\" . $ callback [ 0 ] ; if ( class_exists ( $ class ) ) { call_user_func ( array ( $ this , $ callback [ 1 ] ) ) ; } } e...
run an event on this object
7,922
public function align ( $ direction = 'horizontal' , $ collapse = 'sm' , $ indent = 2 ) { if ( $ direction == 'collapse' ) { $ this -> align = '' ; } elseif ( $ direction == 'inline' ) { $ this -> align = 'form-inline' ; } else { $ this -> align = 'form-horizontal' ; $ this -> collapse = ( in_array ( $ collapse , array...
Utilize any Bootstrap form style .
7,923
public function prompt ( $ place , $ html , $ required = false ) { switch ( $ place ) { case 'info' : case 'append' : $ this -> prompt [ $ place ] = $ html ; break ; case 'prepend' : $ this -> prompt [ 'prepend' ] = array ( 'html' => $ html , 'required' => ( bool ) $ required ) ; break ; } }
This is to add html tags or semicolons or asterisks or whatever you would like to all of the form s prompts .
7,924
public function submit ( $ submit = 'Submit' , $ reset = '' ) { $ buttons = func_get_args ( ) ; if ( substr ( $ submit , 0 , 1 ) != '<' ) { $ buttons [ 0 ] = $ this -> page -> tag ( 'button' , array ( 'type' => 'submit' , 'class' => array ( 'btn' , 'btn-primary' , str_replace ( 'input' , 'btn' , $ this -> input ) ) , '...
Quickly adds a submit button to your form .
7,925
public function assignCryptographyEngine ( CryptographyEngine $ cryptographyEngine , $ email ) { $ this -> cryptographyEngine = $ cryptographyEngine ; $ this -> email = $ email ; }
assigns the cryptography engine
7,926
protected function resolveActionFromStdClass ( stdClass $ stdClass ) { if ( isset ( $ stdClass -> data ) ) $ stdClass -> data = $ this -> cryptographyEngine -> decrypt ( $ stdClass -> data , $ this -> email ) ; return Action :: createFromStdClass ( $ stdClass ) ; }
resolves an action from a stdClass
7,927
public function merge ( GDBackend $ image ) { imagealphablending ( $ this -> owner -> getImageResource ( ) , false ) ; imagesavealpha ( $ this -> owner -> getImageResource ( ) , true ) ; imagealphablending ( $ image -> getImageResource ( ) , false ) ; imagesavealpha ( $ image -> getImageResource ( ) , true ) ; $ srcX =...
Merge two Images together
7,928
public function blur ( $ intensity ) { $ image = $ this -> owner -> getImageResource ( ) ; switch ( $ intensity ) { case 'light' : for ( $ x = 1 ; $ x <= 10 ; $ x ++ ) imagefilter ( $ image , IMG_FILTER_GAUSSIAN_BLUR ) ; break ; case 'strong' : for ( $ x = 1 ; $ x <= 40 ; $ x ++ ) imagefilter ( $ image , IMG_FILTER_GAU...
blur the image
7,929
public function toJpeg ( $ backgroundColor , $ type ) { $ image = $ this -> owner -> getImageResource ( ) ; switch ( $ type ) { case IMAGETYPE_GIF : case IMAGETYPE_PNG : $ newGD = imagecreatetruecolor ( $ this -> owner -> getWidth ( ) , $ this -> owner -> getHeight ( ) ) ; $ bg = GDBackend :: color_web2gd ( $ newGD , $...
convert to jpeg
7,930
public function createAdapter ( $ collection ) { if ( \ is_array ( $ collection ) ) { $ className = 'Array' ; } else { try { $ r = new \ ReflectionClass ( $ collection ) ; $ className = $ r -> getName ( ) ; } catch ( \ ReflectionException $ exc ) { throw new AdapterNotSupportedException ( $ collection ) ; } } $ adapter...
This method recieve a data collection and returns the corresponding adapter .
7,931
public function appendConfiguration ( ArrayNodeDefinition $ rootNode ) { $ rootNode -> children ( ) -> arrayNode ( 'vcs' ) -> children ( ) -> scalarNode ( 'url' ) -> end ( ) -> arrayNode ( 'export' ) -> children ( ) -> scalarNode ( 'revfile' ) -> isRequired ( ) -> end ( ) -> end ( ) -> end ( ) -> end ( ) -> end ( ) -> ...
Appends Git configuration options
7,932
protected function setRegistryWritableFalse ( ) { foreach ( $ this -> lookup_pool as $ reg ) { if ( $ reg instanceof WritableInterface && ! $ reg -> setWritable ( false ) ) { return false ; } } return true ; }
Set writable to FALSE in all registries
7,933
public function setQuad ( Quad $ quad ) { $ quad -> checkId ( ) ; $ quad -> setScriptEvents ( true ) ; $ this -> quad = $ quad ; return $ this ; }
Set the CheckBox Quad
7,934
public static function write ( $ path , $ content ) { static :: mkdir ( $ path ) ; if ( file_put_contents ( $ path , $ content , LOCK_EX ) === false ) { if ( static :: _can_print ( ) ) { CCCli :: line ( CCCli :: color ( 'failure' , 'red' ) . ' creating ' . $ path ) ; } return false ; } if ( static :: _can_print ( ) ) {...
save a file
7,935
public static function append ( $ path , $ content ) { if ( ! is_dir ( dirname ( $ path ) ) ) { if ( ! mkdir ( dirname ( $ path ) , 0755 , true ) ) { throw new CCException ( "CCFile - could not create directory: " . dirname ( $ path ) ) ; } } return file_put_contents ( $ path , $ content , LOCK_EX | FILE_APPEND ) ; }
append to a file
7,936
public static function delete ( $ path ) { $ success = false ; if ( file_exists ( $ path ) ) { $ success = unlink ( $ path ) ; } if ( static :: _can_print ( ) ) { if ( $ success ) { CCCli :: line ( CCCli :: color ( 'removed' , 'green' ) . ' ' . $ path ) ; } else { CCCli :: line ( CCCli :: color ( 'removing failure' , '...
Delete a file This function is going to remove a file from your filesystem
7,937
public static function upload ( $ key , $ path ) { if ( $ file = static :: upload_path ( $ key ) ) { return move_uploaded_file ( $ file , $ path ) ; } return false ; }
Move user uploads to another dir
7,938
public static function _init ( ) { if ( ClanCats :: in_development ( ) ) { CCEvent :: mind ( 'response.output' , function ( $ output ) { if ( strpos ( $ output , '</body>' ) === false ) { return $ output ; } $ table = \ UI \ Table :: create ( array ( 'style' => array ( 'width' => '100%' , ) , 'cellpadding' => '5' , 'cl...
error class init
7,939
private static function is_fatal_level ( $ level ) { $ fatals = array ( E_ERROR , E_PARSE , E_CORE_ERROR , E_CORE_WARNING , E_COMPILE_ERROR , E_COMPILE_WARNING , E_DEPRECATED , ) ; if ( is_object ( ClanCats :: $ config ) && ClanCats :: $ config instanceof CCConfig ) { if ( in_array ( $ level , ClanCats :: $ config -> g...
check if a level is fatal
7,940
public static function error ( $ num , $ message , $ file , $ line ) { $ exception = new CCException ( static :: $ error_types [ $ num ] . " - " . $ message , 0 , $ num , $ file , $ line ) ; if ( static :: is_fatal_level ( $ num ) ) { if ( static :: $ in_shutdown_process ) { static :: exception ( $ exception ) ; } else...
The error handler converts PHP errors to CCExceptions . These get handled by the CCError exception handler .
7,941
public function init ( ) { parent :: init ( ) ; if ( ! empty ( $ this -> theme ) && ! in_array ( $ this -> theme , $ this -> _supportedThemes ) ) { throw new InvalidConfigException ( 'Unsupported built-in theme : ' . $ this -> theme ) ; } if ( isset ( $ this -> pluginOptions [ 'animation' ] ) && ! in_array ( $ this -> ...
Chekcs validity of theme and animation options
7,942
public function registerClientScript ( ) { $ view = $ this -> getView ( ) ; if ( isset ( $ this -> theme ) ) { $ path = $ view -> getAssetManager ( ) -> publish ( __DIR__ . '/assets/css/themes' ) ; $ view -> registerCSSFile ( $ path [ 1 ] . '/' . $ this -> theme . '.css' ) ; if ( $ this -> theme == 'image' && isset ( $...
Registers the needed JavaScript and inject the JS initialization code .
7,943
public function getLocation ( $ position ) { $ pattern = '/\r\n|[\n\r\u2028\u2029]/g' ; $ subject = mb_substr ( $ this -> body , 0 , $ position , 'UTF-8' ) ; preg_match_all ( $ pattern , $ subject , $ matches , PREG_OFFSET_CAPTURE ) ; $ location = array_reduce ( $ matches [ 0 ] , function ( $ carry , $ match ) use ( $ ...
Takes a Source and a UTF - 8 character offset and returns the corresponding line and column as a SourceLocation .
7,944
public function addChild ( & $ child ) { JLog :: add ( 'JNode::addChild() is deprecated.' , JLog :: WARNING , 'deprecated' ) ; if ( $ child instanceof Jnode ) { $ child -> setParent ( $ this ) ; } }
Add child to this node
7,945
public function setParent ( & $ parent ) { JLog :: add ( 'JNode::setParent() is deprecated.' , JLog :: WARNING , 'deprecated' ) ; if ( $ parent instanceof JNode || is_null ( $ parent ) ) { $ hash = spl_object_hash ( $ this ) ; if ( ! is_null ( $ this -> _parent ) ) { unset ( $ this -> _parent -> children [ $ hash ] ) ;...
Set the parent of a this node
7,946
private function registerFactories ( ContainerBuilder $ container , Definition $ clientService , $ clientName ) { $ container -> setDefinition ( sprintf ( 'kch_sms_api.sms_factory.%s' , $ clientName ) , new Definition ( '%kch_sms_api.sms_factory.class%' ) ) -> addMethodCall ( 'setClient' , array ( $ clientService ) ) -...
Method register all library factories for Client .
7,947
public function isMetaProperty ( $ property ) { if ( array_key_exists ( $ property -> getName ( ) , $ this -> forcedMetaProperties ) ) return $ this -> forcedMetaProperties [ $ property -> getName ( ) ] ; return TRUE ; }
Soll dsa Property z . b . im SetMetaGetter genannt werden?
7,948
public function get ( $ key , $ default = null ) { if ( ! isset ( $ this -> GET [ $ key ] ) ) { return $ default ; } return $ this -> GET [ $ key ] ; }
get a GET param
7,949
public function post ( $ key , $ default = null ) { if ( ! isset ( $ this -> POST [ $ key ] ) ) { return $ default ; } return $ this -> POST [ $ key ] ; }
get a POST param
7,950
public function server ( $ key , $ default = null ) { if ( ! isset ( $ this -> SERVER [ strtoupper ( $ key ) ] ) ) { return $ default ; } return $ this -> SERVER [ strtoupper ( $ key ) ] ; }
get a SERVER param
7,951
public function file ( $ key , $ default = null ) { if ( ! isset ( $ this -> FILES [ $ key ] ) ) { return $ default ; } return $ this -> FILES [ $ key ] ; }
get a FILE param
7,952
public function client ( $ key = null ) { if ( is_null ( $ this -> client ) ) { $ this -> client = new \ stdClass ; if ( $ this -> has_server ( 'HTTP_CF_CONNECTING_IP' ) ) { $ this -> client -> ip = $ this -> server ( 'HTTP_CF_CONNECTING_IP' ) ; } elseif ( $ this -> has_server ( 'HTTP_X_FORWARDED_FOR' ) ) { $ this -> c...
get the client data
7,953
public function method ( $ is = null ) { if ( ! is_null ( $ is ) ) { return strtoupper ( $ is ) === $ this -> method ( ) ; } return strtoupper ( $ this -> server ( 'HTTP_X_HTTP_METHOD_OVERRIDE' , $ this -> server ( 'REQUEST_METHOD' , 'GET' ) ) ) ; }
get the current requesting method GET POST PUT DELETE
7,954
public function uri ( $ full = false ) { if ( is_null ( $ this -> uri ) ) { $ this -> uri = $ this -> server ( 'REQUEST_URI' , '/' ) ; $ this -> uri = preg_replace ( '/(\/+)/' , '/' , $ this -> uri ) ; if ( ! $ full ) { $ this -> uri = CCStr :: cut ( $ this -> uri , '?' ) ; } $ this -> uri = substr ( $ this -> uri , st...
get the requestet uri
7,955
public function connect ( $ conf ) { $ connection_params = array ( ) ; foreach ( $ conf as $ key => $ value ) { if ( is_string ( $ value ) ) { $ connection_params [ '{' . $ key . '}' ] = $ value ; } } $ connection_string = \ CCStr :: replace ( $ this -> connection_string , $ connection_params ) ; $ this -> connection =...
connect to database
7,956
public static function __callHandler ( $ index , $ value , array $ handler ) { $ promise = $ handler [ 0 ] ; if ( $ promise -> getState ( ) !== self :: PENDING ) { return ; } try { if ( isset ( $ handler [ $ index ] ) ) { $ promise -> resolve ( call_user_func ( $ handler [ $ index ] , $ value ) ) ; } elseif ( $ index =...
Call a stack of handlers using a specific callback index and value .
7,957
public function _add_localize_script ( ) { $ handle = get_template ( ) ; if ( ! wp_script_is ( get_template ( ) ) && wp_script_is ( get_stylesheet ( ) ) ) { $ handle = get_stylesheet ( ) ; } $ handle = apply_filters ( 'inc2734_wp_share_buttons_localize_script_handle' , $ handle ) ; wp_localize_script ( $ handle , 'inc2...
Setup localize script
7,958
public function get ( $ key = null ) { if ( Arr :: key ( $ key , $ this -> _data ) ) { return $ this -> _data [ $ key ] ; } return $ this -> _data ; }
Get replacement val or all list .
7,959
public function set ( $ key , $ val ) { $ this -> _data = Hash :: merge ( [ $ key => $ val ] , $ this -> _data ) ; return $ this ; }
Add new value in list .
7,960
public function text ( $ text ) { foreach ( $ this -> _data as $ macros => $ value ) { $ macros = '{' . $ macros . '}' ; $ text = preg_replace ( '#' . $ macros . '#ius' , $ value , $ text ) ; } return $ text ; }
Get replacement text .
7,961
public function exception ( $ exception , $ user_message = null ) { if ( $ exception instanceof \ Exception == false ) { return $ this -> error ( 'unknown exception format' , response :: STATUS_INTERNAL_SERVER_ERROR ) ; } $ exception_class = bootstrap :: get_library ( 'exception' ) ; $ this -> data [ 'exception' ] [ 'c...
show an error page using an exception
7,962
public function error ( $ reason = null , $ code = response :: STATUS_INTERNAL_SERVER_ERROR , $ user_message = null ) { $ response = bootstrap :: get_library ( 'response' ) ; $ error_data = [ 'status_code' => $ code , 'status_message' => $ response :: get_status_message ( $ code ) , ] ; $ error_data [ 'status_code_is_'...
show an error page
7,963
private static function show_default_error ( $ error_data ) { $ template_path = \ alsvanzelf \ fem \ ROOT_DIR . 'vendor/alsvanzelf/fem/src/templates/default_error.html' ; $ template_content = file_get_contents ( $ template_path ) ; $ renderer = new \ Mustache_Engine ( ) ; echo $ renderer -> render ( $ template_content ...
shows a default error template in case no specific one is set
7,964
protected static function __orCombinator ( array $ fs , $ a ) { return self :: any ( Arrays :: map ( function ( $ c ) use ( $ a ) { return $ c ( $ a ) ; } , $ fs ) ) ; }
Logical Or Combinator
7,965
protected static function __andCombinator ( array $ fs , $ a ) { return self :: all ( Arrays :: map ( function ( $ c ) use ( $ a ) { return $ c ( $ a ) ; } , $ fs ) ) ; }
Logical And Combinator
7,966
public function loadAllowance ( $ request , $ action ) { $ allowance = Yii :: $ app -> cache -> get ( $ action -> controller -> id . ':' . $ action -> id . ':' . $ this -> id . '_allowance' ) ; $ allowanceUpdatedAt = Yii :: $ app -> cache -> get ( $ action -> controller -> id . ':' . $ action -> id . ':' . $ this -> id...
Loads the number of allowed requests and the corresponding timestamp from a persistent storage .
7,967
public function saveAllowance ( $ request , $ action , $ allowance , $ timestamp ) { Yii :: $ app -> cache -> set ( $ action -> controller -> id . ':' . $ action -> id . ':' . $ this -> id . '_allowance' , $ allowance , 60 ) ; Yii :: $ app -> cache -> set ( $ action -> controller -> id . ':' . $ action -> id . ':' . $ ...
Saves the number of allowed requests and the corresponding timestamp to a persistent storage .
7,968
public function rgbXY ( $ x , $ y ) { $ color = $ this -> colorXY ( $ x , $ y ) ; return array ( ( $ color >> 16 ) & 0xFF , ( $ color >> 8 ) & 0xFF , $ color & 0xFF ) ; }
Returns RGB array of pixel s color
7,969
public function create ( ) { switch ( $ this -> info [ 2 ] ) { case IMAGETYPE_JPEG : $ this -> resource = imagecreatefromjpeg ( $ this -> file ) ; break ; case IMAGETYPE_GIF : $ this -> resource = imagecreatefromgif ( $ this -> file ) ; break ; case IMAGETYPE_PNG : $ this -> resource = imagecreatefrompng ( $ this -> fi...
Create an image resource
7,970
public function save ( $ file , $ type = IMAGETYPE_JPEG , $ quality = 75 , $ permissions = false ) { $ dir = dirname ( $ file ) ; if ( ! file_exists ( $ dir ) ) { $ mask = umask ( ) ; mkdir ( $ dir , 0777 , true ) ; umask ( $ mask ) ; } switch ( $ type ) { case IMAGETYPE_JPEG : imagejpeg ( $ this -> resource , $ file ,...
Save image to file
7,971
public function fitResize ( $ max_width = 150 , $ max_height = 150 , $ min_width = 20 , $ min_height = 20 ) { $ kw = $ max_width / $ this -> width ( ) ; $ kh = $ max_height / $ this -> height ( ) ; if ( $ kw > $ kh ) { $ new_h = $ max_height ; $ new_w = round ( $ kh * $ this -> width ( ) ) ; } else { $ new_w = $ max_wi...
Fit the image with the same proportion into an area
7,972
public function scaleResize ( $ width , $ height ) { $ kw = $ this -> width ( ) / $ width ; $ kh = $ this -> height ( ) / $ height ; if ( $ kh < $ kw ) { $ src_h = $ this -> height ( ) ; $ src_y = 0 ; $ src_w = round ( $ kh * $ width ) ; $ src_x = round ( ( $ this -> width ( ) - $ src_w ) / 2 ) ; } else { $ src_h = rou...
Resize image correctly scaled and than crop the necessary area
7,973
public function getAttribute ( $ attributes , $ name ) { foreach ( $ attributes as $ a ) { if ( $ a -> key == $ name ) { return $ a -> value ; } } return null ; }
Returns the value of attribute with name
7,974
public function getAuthToken ( ) { try { $ response = $ this -> client -> request ( 'GET' , "authenticate/accessToken" , [ 'headers' => [ 'x-api-client-id' => $ this -> clientId , 'x-api-key' => $ this -> apiKey ] ] ) ; $ this -> authToken = json_decode ( $ response -> getBody ( ) ) -> token ; return $ this -> authToke...
Gets an authorization token using the clients API key . Most requests to the SafeStream API require an authorization token .
7,975
protected function getReadableTime ( $ time , $ percision = 3 ) { $ unit = 's' ; if ( $ time < 1 ) { $ time *= 1000 ; $ percision = 0 ; $ unit = 'ms' ; } elseif ( $ time > 60 ) { $ time /= 60 ; $ unit = 'm' ; } $ time = number_format ( $ time , $ percision ) ; return "{$time} {$unit}" ; }
Formatter for human - readable time Only handles time up to 60 minutes gracefully
7,976
protected function getReadableMemory ( $ size , $ percision = 2 ) { $ unitOptions = array ( 'b' , 'k' , 'M' , 'G' ) ; $ base = log ( $ size , 1024 ) ; $ memory = round ( pow ( 1024 , $ base - floor ( $ base ) ) , $ percision ) ; $ unit = $ unitOptions [ floor ( $ base ) ] ; return "{$memory} {$unit}" ; }
Formatter for human - readable memory Only handles time up to a few gigs gracefully
7,977
public function addContentElement ( ApiElement $ element ) { $ newContent = [ ] ; $ rawElements = [ ] ; $ content = $ this -> getContent ( ) ; if ( $ this -> hasCopy ( ) ) { $ newContent [ ] = array_shift ( $ content ) ; } foreach ( $ content as $ resourceGroup ) { if ( ! is_array ( $ resourceGroup ) ) { $ newContent [...
Add content element to the current content
7,978
public function getCopyText ( ) { $ content = $ this -> getContent ( ) ; $ copy = array_shift ( $ content ) ; if ( ! is_array ( $ copy ) ) { return null ; } if ( $ copy [ 'element' ] !== 'copy' ) { return null ; } return $ copy [ 'content' ] ; }
Get the copy text of the current element ; raw markdown likely
7,979
public function hasClass ( $ className ) { foreach ( $ this -> meta [ 'classes' ] as $ classInMeta ) { if ( $ classInMeta === $ className ) { return true ; } } return false ; }
Check whether or not this element has a given class
7,980
public function addTOC ( $ styleFont = null , $ styleTOC = null ) { $ toc = new PHPWord_TOC ( $ styleFont , $ styleTOC ) ; $ this -> _elementCollection [ ] = $ toc ; return $ toc ; }
Add a Table - of - Contents Element
7,981
public function addTitle ( $ text , $ depth = 1 ) { $ styles = PHPWord_Style :: getStyles ( ) ; if ( array_key_exists ( 'Heading_' . $ depth , $ styles ) ) { $ style = 'Heading' . $ depth ; } else { $ style = null ; } $ title = new PHPWord_Section_Title ( $ text , $ depth , $ style ) ; $ data = PHPWord_TOC :: addTitle ...
Add a Title Element
7,982
public function deleteContainers ( $ containers , $ force = false ) { if ( ! empty ( $ containers ) ) { if ( ! isset ( $ containers [ 0 ] ) ) { $ containers = [ $ containers ] ; } foreach ( $ containers as $ key => $ folder ) { try { $ name = array_get ( $ folder , 'name' , trim ( array_get ( $ folder , 'path' ) , '/' ...
Delete multiple containers and all of their content
7,983
public function msginitFile ( string $ filename ) : PoFile { if ( ! is_readable ( $ filename ) ) { $ source = false ; } else { $ source = file_get_contents ( $ filename ) ; } if ( false === $ source ) { throw new FileNotReadableException ( $ filename ) ; } return $ this -> msginitString ( $ source , $ filename ) ; }
Inspect the supplied source file capture gettext references as a PoFile object
7,984
public function escapeForPo ( string $ string ) : string { if ( $ string [ 0 ] == '"' || $ string [ 0 ] == "'" ) { $ string = substr ( $ string , 1 , - 1 ) ; } $ string = str_replace ( "\r\n" , "\n" , $ string ) ; $ string = stripcslashes ( $ string ) ; return addcslashes ( $ string , "\0..\37\"" ) ; }
Prepare a string from tokenized output for use in a po file . Remove any surrounding quotes escape control characters and double quotes .
7,985
public function checkPhpFormatFlag ( PoEntry $ entry ) : void { if ( preg_match ( '#(?<!%)%(?:\d+\$)?[+-]?(?:[ 0]|\'.{1})?-?\d*(?:\.\d+)?[bcdeEufFgGosxX]#' , $ entry -> get ( PoTokens :: MESSAGE ) . $ entry -> get ( PoTokens :: PLURAL ) ) ) { $ entry -> addFlag ( 'php-format' ) ; } }
Check the supplied entry for sprintf directives and set php - format flag if found
7,986
public function perform ( ) { $ declaration = $ this -> createDeclaration ( compact ( 'alias' ) ) ; $ declaration -> setAlias ( $ this -> argument ( 'alias' ) ?? $ this -> argument ( 'name' ) ) ; $ declaration -> setDescription ( ( string ) $ this -> option ( 'description' ) ) ; $ this -> writeDeclaration ( $ declarati...
Create command declaration .
7,987
public function isGroupCenterPresentOnce ( ExecutionContextInterface $ context ) { $ groupCentersIds = array ( ) ; foreach ( $ this -> getGroupCenters ( ) as $ groupCenter ) { if ( in_array ( $ groupCenter -> getId ( ) , $ groupCentersIds ) ) { $ context -> buildViolation ( "The user has already those permissions" ) ->...
This function check that groupCenter are present only once . The validator use this function to avoid a user to be associated to the same groupCenter more than once .
7,988
public static function stringStartsWith ( $ str , $ prefix ) { if ( is_array ( $ prefix ) ) { foreach ( $ prefix as $ p ) { if ( $ p === "" || strpos ( $ str , $ p ) === 0 ) { return true ; } ; } return false ; } return $ prefix === "" || strpos ( $ str , $ prefix ) === 0 ; }
Does a string start with another string?
7,989
public static function stringEndsWith ( $ str , $ postfix ) { if ( is_array ( $ postfix ) ) { foreach ( $ postfix as $ p ) { if ( $ p === "" || substr ( $ str , - strlen ( $ p ) ) === $ p ) { return true ; } } return false ; } return $ postfix === "" || substr ( $ str , - strlen ( $ postfix ) ) === $ postfix ; }
Does a string end with another string?
7,990
public function toArray ( ) { $ data = array ( 'name' => $ this -> name , 'hash' => $ this -> hash , 'phash' => $ this -> phash , 'mime' => $ this -> mime , 'ts' => $ this -> ts , 'size' => $ this -> size , 'dirs' => $ this -> dirs , 'read' => $ this -> read , 'write' => $ this -> write , 'locked' => $ this -> locked ,...
FileInfo return as array .
7,991
public static function create ( $ quantity , $ productCode , $ description , $ amount , $ vat , $ currency = "EUR" ) { $ item = new LineItem ; $ item -> quantity = $ quantity ; $ item -> productCode = $ productCode ; $ item -> description = $ description ; $ item -> amount = $ amount ; $ item -> vat = $ vat ; $ item ->...
LineItem creator .
7,992
public static function create ( $ modelAlias = null , $ criteria = null ) { if ( $ criteria instanceof CountryQuery ) { return $ criteria ; } $ query = new CountryQuery ( null , null , $ modelAlias ) ; if ( $ criteria instanceof Criteria ) { $ query -> mergeWith ( $ criteria ) ; } return $ query ; }
Returns a new CountryQuery object .
7,993
public function filterByEn ( $ en = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ en ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ en ) ) { $ en = str_replace ( '*' , '%' , $ en ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( Co...
Filter the query on the en column
7,994
public function filterByDe ( $ de = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ de ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ de ) ) { $ de = str_replace ( '*' , '%' , $ de ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( Co...
Filter the query on the de column
7,995
public function addStyle ( Style $ style ) { if ( ! in_array ( $ style , $ this -> styles , true ) ) { array_push ( $ this -> styles , $ style ) ; } return $ this ; }
Add a new Style
7,996
public function addStyle3d ( Style3d $ style3d ) { if ( ! in_array ( $ style3d , $ this -> styles3d , true ) ) { array_push ( $ this -> styles3d , $ style3d ) ; } return $ this ; }
Add a new Style3d
7,997
public function getMood ( $ createIfEmpty = true ) { if ( ! $ this -> mood && $ createIfEmpty ) { $ this -> createMood ( ) ; } return $ this -> mood ; }
Get the Mood
7,998
public function createMood ( ) { if ( $ this -> mood ) { return $ this -> mood ; } $ mood = new Mood ( ) ; $ this -> setMood ( $ mood ) ; return $ this -> mood ; }
Create a new Mood if necessary
7,999
public function render ( \ DOMDocument $ domDocument ) { $ stylesheetXml = $ domDocument -> createElement ( "stylesheet" ) ; if ( $ this -> styles3d ) { $ stylesXml = $ domDocument -> createElement ( "frame3dstyles" ) ; $ stylesheetXml -> appendChild ( $ stylesXml ) ; foreach ( $ this -> styles3d as $ style3d ) { $ sty...
Render the Stylesheet