idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
51,800
public function actionDaily ( ) { $ this -> stdout ( "Executing daily tasks:" . PHP_EOL , Console :: FG_YELLOW ) ; $ this -> trigger ( self :: EVENT_ON_DAILY_RUN ) ; Yii :: $ app -> settings -> set ( 'cronLastDailyRun' , time ( ) , 'core' ) ; return ExitCode :: OK ; }
Executes daily cron tasks .
51,801
public function actionMonth ( ) { $ this -> stdout ( "Executing month tasks:" . PHP_EOL , Console :: FG_YELLOW ) ; $ this -> trigger ( self :: EVENT_ON_MONTH_RUN ) ; Yii :: $ app -> settings -> set ( 'cronLastMonthRun' , time ( ) , 'core' ) ; return ExitCode :: OK ; }
Executes month cron tasks .
51,802
public function getImageResizeDefinitionByWidth ( $ width ) { if ( ! key_exists ( $ width , $ this -> irds ) ) { throw new WidthNotAllowedException ( $ width ) ; } return $ this -> irds [ $ width ] ; }
Get an ImageResizeDefinition for a given width
51,803
public function setScaleAlgorithm ( $ algorithm ) { foreach ( $ this -> available_image_widths as $ width ) { $ this -> irds [ $ width ] -> setScaleAlgorithm ( $ algorithm ) ; } return $ this ; }
Set the algorithm used for scaling
51,804
public function getTotalDays ( ) { $ dt = new \ DateTimeImmutable ( ) ; return $ dt -> add ( $ this -> Value ) -> diff ( $ dt ) -> days ; }
Return the total days of the duration
51,805
public static function hasValue ( $ di ) { $ components = array ( "s" , "i" , "h" , "d" , "m" , "y" ) ; $ hasValue = false ; foreach ( $ components as $ component ) { $ hasValue = isset ( $ di -> $ component ) && $ di -> $ component != 0 ; if ( $ hasValue ) break ; } return $ hasValue ; }
Returns true if the date interval parameter has a non zero value
51,806
public function compile ( ExpressCompiler $ compiler , $ flags = 0 ) { try { if ( $ flags & self :: FLAG_RAW ) { if ( empty ( $ this -> childNodes ) ) { $ compiler -> write ( "''" ) ; } else { $ compiler -> write ( '(' ) ; foreach ( $ this -> childNodes as $ i => $ node ) { if ( $ i > 0 ) { $ compiler -> write ( ' . ' ...
Compile the attribute value into it s PHP code .
51,807
public function loadClassMetadata ( LoadClassMetadataEventArgs $ args ) { if ( empty ( $ this -> prefix ) ) { return ; } $ classMetadata = $ args -> getClassMetadata ( ) ; if ( false === strpos ( $ classMetadata -> getTableName ( ) , $ this -> prefix ) ) { $ tableName = $ this -> prefix . $ classMetadata -> getTableNam...
Load class meta data event
51,808
public function init ( ) { parent :: init ( ) ; Yii :: setAlias ( 'foxslider' , dirname ( dirname ( dirname ( __DIR__ ) ) ) ) ; $ this -> registerComponents ( ) ; }
Initialize the services .
51,809
private function checkInputs ( $ short , $ long ) { $ key = array_search ( $ short , $ this -> inputs ) ; if ( $ key === false ) { $ key = array_search ( $ long , $ this -> inputs ) ; if ( $ key === false ) { return false ; } else { return $ key ; } } else { return $ key ; } }
Check input for flag
51,810
private function checkRequired ( ) { foreach ( $ this -> params as $ param ) { if ( array_key_exists ( 'required' , $ param ) && $ param [ 'required' ] == true ) { if ( ! array_key_exists ( $ param [ 'name' ] , $ this -> pinputs ) ) { throw new \ Exception ( 'Parameter "' . $ param [ 'name' ] . '" is required' ) ; } } ...
Check required options If a required option is not provided then throw and exception
51,811
public static function confirm ( $ msg ) { echo $ msg ; $ input = trim ( fgets ( STDIN ) ) ; if ( strtolower ( $ input ) == 'y' || strtolower ( $ input ) == 'yes' ) { return true ; } else { return false ; } }
Add a confirmation
51,812
public function outputHelp ( $ short = false ) { echo "Usage: " . $ this -> getName ( ) . " " ; if ( ! empty ( $ this -> params ) ) { foreach ( $ this -> params as $ param ) { if ( $ param [ 'required' ] == true ) { echo '<' . $ param [ 'name' ] . '> ' ; } else { echo '[' . $ param [ 'name' ] . '] ' ; } } } echo "[opti...
Output help text
51,813
private function writeLine ( string $ str ) { $ now = time ( ) ; if ( $ this -> file && $ this -> file_opened < $ now - $ this -> reopen_interval ) { fclose ( $ this -> file ) ; $ this -> file = null ; } if ( ! $ this -> file ) { touch ( $ this -> filename ) ; try { Hook :: execute ( "Wedeto.IO.FileCreated" , [ 'path' ...
Write a line to the log file
51,814
public function insertOrUpdate ( $ tableORq , $ data ) { if ( is_string ( $ tableORq ) ) { $ this -> defaults [ 'table' ] = $ tableORq ; $ tableORq = [ ] ; } extract ( $ this -> defaults ) ; extract ( $ tableORq ) ; if ( ! $ table ) throw new Exception ( "table [$tabel] not defined" , 1 ) ; $ sql = 'INSERT OR REPLACE I...
inserts or update a record
51,815
protected function Init ( ) { $ htmlCode = ContentHtmlCode :: Schema ( ) -> ByContent ( $ this -> content ) ; $ this -> code = $ htmlCode -> GetCode ( ) ; return parent :: Init ( ) ; }
Initializes the html code frontend module
51,816
public function BackendName ( ) { $ result = 'code' ; if ( ! $ this -> content ) { return $ result ; } $ htmlCode = ContentHtmlCode :: Schema ( ) -> ByContent ( $ this -> content ) ; $ code = Text :: Shorten ( $ htmlCode -> GetCode ( ) ) ; if ( $ code ) { $ result .= ' - ' . $ code ; } return $ result ; }
The backend name for the code
51,817
public function pass ( ) { $ action = $ this -> getParameter ( 'action' ) ; return $ this -> Permissions -> checkPermission ( $ action , $ this -> getLocal ( 'SiteSlug' ) ) ; }
Checks if the specified action is granted to the current user
51,818
public function required ( $ input , $ key , $ lang ) { $ lang = $ this -> custom ( 'required' , $ lang ) ; if ( empty ( $ input [ $ key ] ) ) { return str_replace ( ':field' , $ key , $ lang ) ; } }
Parses a required validation field .
51,819
public function match ( $ input , $ key , $ match , $ lang ) { $ lang = $ this -> custom ( 'match' , $ lang ) ; if ( $ input [ $ key ] !== $ input [ $ match ] ) { return preg_replace_callback ( '/(\:field)(.*)(\:match)/i' , function ( $ m ) use ( $ key , $ match ) { return $ key . $ m [ 2 ] . $ match ; } , $ lang ) ; }...
Parses a match validation field .
51,820
public function email ( $ input , $ key , $ lang ) { $ lang = $ this -> custom ( 'email' , $ lang ) ; if ( filter_var ( $ input [ $ key ] , FILTER_VALIDATE_EMAIL ) === false ) { return str_replace ( ':field' , $ key , $ lang ) ; } }
Parses an email validation field .
51,821
public function url ( $ input , $ key , $ lang ) { $ lang = $ this -> custom ( 'url' , $ lang ) ; if ( filter_var ( $ input [ $ key ] , FILTER_VALIDATE_URL ) === false ) { return str_replace ( ':field' , $ key , $ lang ) ; } }
Parses URL validation field .
51,822
public function min ( $ input , $ key , $ min , $ lang ) { $ lang = $ this -> custom ( 'min' , $ lang ) ; if ( strlen ( $ input [ $ key ] ) < $ min ) { return preg_replace_callback ( '/(:field)(.*)(\:num)/i' , function ( $ m ) use ( $ key , $ min ) { return $ key . $ m [ 2 ] . $ min ; } , $ lang ) ; } }
Parses a set minimum number of characters .
51,823
public function max ( $ input , $ key , $ max , $ lang ) { $ lang = $ this -> custom ( 'max' , $ lang ) ; if ( strlen ( $ input [ $ key ] ) > $ max ) { return preg_replace_callback ( '/(:field)(.*)(\:num)/i' , function ( $ m ) use ( $ key , $ max ) { return $ key . $ m [ 2 ] . $ max ; } , $ lang ) ; } }
Parses a set maximum number of characters .
51,824
public function from ( $ input , $ key , $ rule , $ lang ) { $ lang = $ this -> custom ( 'from' , $ lang ) ; $ db = new Database ( ) ; $ cap = $ db -> getCapsule ( ) ; $ exp = explode ( ':' , $ rule ) ; $ table = $ cap -> table ( $ exp [ 1 ] ) ; if ( $ table -> where ( $ exp [ 2 ] , '=' , $ input [ $ key ] ) -> count (...
Checks if a given field exists in given database table .
51,825
protected function setQueryController ( $ namespace , $ crud_type = 'Read' ) { $ options = $ this -> setQueryOptions ( $ crud_type ) ; try { $ this -> query = $ this -> resource -> get ( 'query://' . $ namespace , $ options ) ; } catch ( Exception $ e ) { throw new RuntimeException ( $ e -> getMessage ( ) ) ; } return ...
Set Query Controller
51,826
protected function setQueryOptions ( $ crud_type = 'Read' ) { $ options = array ( ) ; $ crud_type = ucfirst ( strtolower ( $ crud_type ) ) ; if ( $ crud_type === 'Create' || $ crud_type === 'Read' || $ crud_type === 'Update' || $ crud_type === 'Delete' ) { } else { $ crud_type = 'Read' ; } $ options [ 'crud_type' ] = $...
Set Query Options
51,827
protected function setQueryControllerDefaults ( $ process_events = 0 , $ query_object = 'item' , $ get_customfields = 0 , $ use_special_joins = 0 , $ use_pagination = 0 , $ check_view_level_access = 0 , $ get_item_children = 0 ) { $ this -> query -> setModelRegistry ( 'process_events' , $ process_events ) ; $ this -> q...
Set Query Controller Default Values
51,828
protected function setModelRegistryCriteria ( ) { $ prefix = $ this -> query -> getModelRegistry ( 'primary_prefix' , 'a' ) ; $ this -> setModelRegistryCatalogTypeIdCriteria ( $ prefix ) ; $ this -> setModelRegistryExtensionInstanceIdCriteria ( $ prefix ) ; $ this -> setModelRegistryMenuIdCriteria ( $ prefix ) ; $ this...
Set Standard Model Registry Criteria
51,829
protected function setStandardFields ( $ data , array $ model_registry = array ( ) ) { $ fields = $ model_registry [ 'fields' ] ; $ this -> customfieldgroups = $ model_registry [ 'customfieldgroups' ] ; $ base = $ this -> processQueryFields ( $ data , $ fields ) ; return $ this -> sortObject ( $ base ) ; }
Set Standard Fields
51,830
protected function setCustomFields ( $ base , $ data , array $ model_registry = array ( ) ) { if ( count ( $ this -> customfieldgroups ) > 0 ) { } else { return $ base ; } foreach ( $ this -> customfieldgroups as $ group ) { $ group_data = $ this -> processQueryFields ( json_decode ( $ data -> $ group ) , $ model_regis...
Set Custom Fields
51,831
protected function verifyFieldDefined ( $ key , $ field ) { if ( count ( $ field ) === 0 ) { throw new RuntimeException ( get_class ( $ this ) . ' Field: ' . $ key . ' not defined ' . ' in QueryUsageTrait::processQueryFields.' ) ; } return $ this ; }
Verify Field is Defined
51,832
protected function setFieldValue ( $ key , $ data , $ default = null ) { $ value = null ; if ( isset ( $ data -> $ key ) ) { $ value = $ data -> $ key ; } if ( $ value === null ) { $ value = $ default ; } return $ value ; }
Set Value for Field
51,833
protected function sortObject ( $ object ) { $ sort_array = get_object_vars ( $ object ) ; ksort ( $ sort_array ) ; $ new_object = new stdClass ( ) ; foreach ( $ sort_array as $ key => $ value ) { if ( is_object ( $ value ) ) { $ value = $ this -> sortObject ( $ value ) ; } $ new_object -> $ key = $ value ; } unset ( $...
Sort an object
51,834
public function sign ( $ data ) { $ privateKeyResource = openssl_pkey_get_private ( 'file://' . $ this -> filePath ) ; $ signature = null ; openssl_sign ( $ data , $ signature , $ privateKeyResource ) ; openssl_free_key ( $ privateKeyResource ) ; return $ signature ; }
Sign some data with this private key .
51,835
public function editSettings ( ) { $ this -> setTitleEditSettings ( ) ; $ this -> setBreadcrumbEditSettings ( ) ; $ this -> setData ( 'statuses' , $ this -> order -> getStatuses ( ) ) ; $ this -> setData ( 'settings' , $ this -> module -> getSettings ( 'twocheckout' ) ) ; $ this -> submitSettings ( ) ; $ this -> output...
Route page callback to display module settings form
51,836
public function toXml ( ) { $ result = '' ; $ tagName = ( $ this -> namespace == '' ? '' : $ this -> namespace . ':' ) . $ this -> name ; $ attributes = '' ; foreach ( $ this -> attributes as $ attribute ) { $ attributes .= ' ' . $ attribute -> Name . '="' . $ attribute -> Value . '"' ; } $ result .= '<' . $ tagName . ...
Convert to XML .
51,837
final public function getAllValues ( ) { $ subClass = get_called_class ( ) ; if ( isset ( $ this -> _cachedEnums [ $ subClass ] ) ) { return FALSE ; } $ reflection = new \ ReflectionClass ( $ subClass ) ; return $ reflection -> getConstants ( ) ; }
Return all populated arrays
51,838
public function afterMethodExecution ( MethodInvocation $ invocation ) { $ filesystemAdapter = new Local ( APP_BASE_DIR . 'storage/cache/api/' ) ; $ filesystem = new Filesystem ( $ filesystemAdapter ) ; $ pool = new FilesystemCachePool ( $ filesystem ) ; $ cacheKey = "products_" . md5 ( implode ( '_' , $ invocation -> ...
Cache bridge file response
51,839
public function reload ( ) : void { $ config = [ ] ; foreach ( $ this -> configSources as $ src ) { if ( is_string ( $ src ) ) { if ( is_dir ( $ src ) ) { $ getConfigFiles = function ( string $ path ) use ( & $ getConfigFiles ) { $ fragments = [ ] ; if ( is_dir ( $ path ) ) { $ d = dir ( $ path ) ; while ( ( $ f = $ d ...
Reload the config from it s sources ( usually done on SIGHUP to load in configuration changes in files
51,840
protected function parseConfig ( string $ config ) : array { $ config = json_decode ( $ config , true ) ; if ( $ config === null ) { throw new ConfigFileFormatException ( "Config files should be written in valid JSON" ) ; } return $ config ; }
An overridable method that allows parsing arbitrary strings into config arrays
51,841
public function actionIndex ( $ lang = '' ) { $ model = new InstallForm ( ) ; if ( ! empty ( $ lang ) ) { Yii :: $ app -> language = $ lang ; $ model -> language = $ lang ; } if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> validate ( ) ) { $ this -> createEnvFile ( $ model ) ; Yii :: $ app ->...
Display the install form
51,842
protected function processMigrations ( ) { $ messages = '' ; $ migrationsPaths = [ '@vendor/dektrium/yii2-user/migrations' , '@yii/rbac/migrations' , '@pheme/settings/migrations' , ] ; foreach ( $ migrationsPaths as $ path ) { $ migration = new Migration ( Yii :: getAlias ( $ path ) ) ; $ migration -> up ( ) ; $ messag...
Process required migrations
51,843
protected function createEnvFile ( InstallForm $ model ) { $ envFile = Yii :: getAlias ( '@app/.env' ) ; if ( ! file_exists ( $ envFile ) ) { $ dsn = '' ; $ buffer = "\n" ; $ cookieKey = $ this -> generateRandomString ( ) ; $ buffer .= "YII_DEBUG = 0\n" ; $ buffer .= "YII_ENV = prod\n" ; $ buffer .= "...
Create the application env file
51,844
protected function callModulesMethod ( $ methodName ) { $ modules = Yii :: $ app -> getModules ( ) ; $ returns = [ ] ; foreach ( $ modules as $ moduleName => $ module ) { if ( is_array ( $ module ) ) { $ module = Yii :: $ app -> getModule ( $ moduleName ) ; } if ( method_exists ( $ module , $ methodName ) ) { $ returns...
Call a method if exists on every application modules
51,845
protected function shouldWriteOutput ( $ min = 0 , $ max = null ) { $ out = $ this -> getOutput ( ) ; if ( ! $ out instanceof OutputInterface ) { return false ; } $ v = $ out -> getVerbosity ( ) ; return ! ( $ v < $ min || ( $ max !== null && $ v > $ max ) ) ; }
Checks if the output verbositiy is between two given levels
51,846
protected function writeOutputLine ( $ msg , $ min = 0 , $ max = null ) { if ( ! $ this -> shouldWriteOutput ( $ min , $ max ) ) { return ; } $ this -> getOutput ( ) -> writeln ( $ msg ) ; }
Prints a text line if the output verbositiy is between two given levels
51,847
protected function writeOutput ( $ msg , $ min = 0 , $ max = null ) { if ( ! $ this -> shouldWriteOutput ( $ min , $ max ) ) { return ; } return $ this -> getOutput ( ) -> write ( $ msg ) ; }
Prints a text if the output verbositiy is between two given levels
51,848
public function makeComponent ( array $ attributes = [ ] , string $ innerHTML = '' , string $ tagName = 'component' ) { $ app = App :: get ( ) ; if ( self :: $ newComponentCache === null ) { self :: $ newComponentCache = new \ IvoPetkov \ BearFramework \ Addons \ HTMLServerComponents \ Internal \ Component ( ) ; } $ co...
Constructs a component object
51,849
public function getPasses ( ) { return array_merge ( array ( $ this -> mergePass ) , $ this -> getBeforeOptimizationPasses ( ) , $ this -> getOptimizationPasses ( ) , $ this -> getBeforeRemovingPasses ( ) , $ this -> getRemovingPasses ( ) , $ this -> getAfterRemovingPasses ( ) ) ; }
Returns all passes in order to be processed .
51,850
public static function ensure ( ) { $ cnt = 0 ; foreach ( self :: $ instances as $ instance ) { if ( ! $ instance -> isAlive ( ) ) { $ instance -> reset ( ) ; $ cnt ++ ; } } return $ cnt ; }
Ensure all known non terminated resource objects are golden
51,851
public function unserialize ( $ data ) { $ connectionSettings = new ConnectionSettings ( json_decode ( $ data , true ) ) ; $ this -> __construct ( $ connectionSettings ) ; }
Unserialize . Object .
51,852
public function isTerminated ( $ throwExceptionIfTerminated = true ) { if ( $ this -> terminated ) { if ( $ throwExceptionIfTerminated ) { throw new ConnectionTerminatedException ( $ this ) ; } return true ; } return false ; }
Has this resource been terminated?
51,853
public function get ( $ reconnectOnFailure = false ) { if ( $ reconnectOnFailure and ! $ this -> isAlive ( ) ) { $ this -> reset ( ) ; } return $ this -> resource ; }
Return the pglink resource .
51,854
public function createInstance ( Binding $ binding , InjectionPointInterface $ point = NULL ) { switch ( $ binding -> getOptions ( ) & BindingInterface :: MASK_TYPE ) { case BindingInterface :: TYPE_ALIAS : return $ this -> get ( $ binding -> getTarget ( ) , $ point ) ; case BindingInterface :: TYPE_FACTORY : case Bind...
Create an instance of the bound type will NOT create or re - use a scoped proxy .
51,855
protected function createObjectUsingFactory ( Binding $ binding , InjectionPointInterface $ point = NULL ) { $ callback = $ binding -> getTarget ( ) ; if ( is_array ( $ callback ) ) { $ callback = [ $ this -> get ( $ callback [ 0 ] ) , $ callback [ 1 ] ] ; $ ref = new \ ReflectionMethod ( get_class ( $ callback [ 0 ] )...
Create an object using the factory defined in the given binding .
51,856
protected function registerBindings ( array $ bindings ) { foreach ( $ bindings as $ binding ) { $ this -> bindings [ ( string ) $ binding ] = $ binding ; foreach ( $ binding -> getMarkers ( ) as $ marker ) { $ marker = get_class ( $ marker ) ; if ( empty ( $ this -> markers [ $ marker ] ) ) { $ this -> markers [ $ mar...
Register the given bindings with the container and prepare markers .
51,857
public function advance ( $ step = 1 , $ redraw = false ) { parent :: advance ( $ step , $ redraw ) ; $ this -> current += $ step ; $ percent = 0 ; if ( $ this -> max > 0 ) { $ percent = ( float ) $ this -> current / $ this -> max ; } $ this -> output -> write ( sprintf ( '%d%%' , floor ( $ percent * 100 ) ) ) ; }
Advances the progress output X steps .
51,858
public function addConnection ( Base $ connection = null , $ name = '' ) { if ( $ connection instanceof Base ) { if ( $ name !== '' ) { $ this -> connections [ $ name ] = $ connection ; } else { $ this -> connections [ ] = $ connection ; } } else { throw new CapsuleInstanceException ( sprintf ( 'Connection variable mus...
add a connection to capsule
51,859
public function deleteConnection ( $ offset ) { if ( isset ( $ this -> connections [ $ offset ] ) ) { unset ( $ this -> connections [ $ offset ] ) ; } return $ this ; }
delete a connection in capsule
51,860
public static function generateProductVariantCode ( ProductInterface $ product , array $ productOptions ) : CodeInterface { $ productVariantCodeGenerator = new ProductVariantCodeGenerator ( ) ; return $ productVariantCodeGenerator -> generate ( $ product -> getCode ( ) , $ productOptions ) ; }
Generate product variant code .
51,861
public function commentsFilter ( ) { $ post_types = get_post_types ( ) ; foreach ( $ post_types as & $ post_type ) { if ( post_type_supports ( $ post_type , 'comments' ) ) { $ post_type_obj = get_post_type_object ( $ post_type ) ; $ post_type = array ( 'name' => $ post_type_obj -> name , 'label' => $ post_type_obj -> l...
Filter comments by post type
51,862
public function queryFilter ( $ query ) { global $ pagenow ; if ( ! is_admin ( ) || ! $ pagenow || $ pagenow !== 'edit-comments.php' || ! isset ( $ _GET [ 'post_type' ] ) || ! $ _GET [ 'post_type' ] ) { return ; } $ query -> set ( 'post_type' , $ _GET [ 'post_type' ] ) ; }
Filter the wp query
51,863
public function tableColumnsContent ( $ column , $ postId ) { if ( $ column == 'post_type' ) { $ comment = get_comment ( $ postId , OBJECT ) ; $ post_type_slug = get_post_type ( $ comment -> comment_post_ID ) ; $ post_type_obj = get_post_type_object ( $ post_type_slug ) ; echo $ post_type_obj -> label ; } }
Content for table columns
51,864
protected function getFileModifiedTimestampOfFile ( $ fileName , $ format = 'Y-m-d H:i:s' , $ resultInUtc = false ) { if ( ! file_exists ( $ fileName ) ) { return [ 'error' => $ fileName . ' was not found' ] ; } $ info = new \ SplFileInfo ( $ fileName ) ; if ( $ format === 'PHPtime' ) { return $ info -> getMTime ( ) ; ...
Returns Modified date and time of a given file
51,865
protected function getPackageDetailsFromGivenComposerLockFileEnhanced ( $ fileIn , $ inParametersArray = [ ] ) { if ( ! file_exists ( $ fileIn ) ) { return [ 'error' => $ fileIn . ' was not found' ] ; } $ alnfo = [ ] ; $ packages = $ this -> getPkgFileInListOfPackageArrayOut ( $ fileIn ) ; $ pkgType = $ this -> decisio...
Returns a complete list of packages and respective details from a composer . lock file
51,866
public function setEmpty ( ) { $ this -> name = $ this -> ANSICode = $ this -> XTermCode = $ this -> RGB = null ; }
Set the color object to empty
51,867
public function isEmpty ( ) { return ( is_null ( $ this -> name ) && is_null ( $ this -> ANSICode ) && is_null ( $ this -> XTermCode ) && is_null ( $ this -> RGB ) ) ; }
Return whether the object is empty
51,868
public function setColor ( $ color ) { if ( ! is_null ( $ color ) ) { if ( $ color instanceof ColorInterface ) { $ this -> name = $ color -> getName ( ) ; $ this -> XTermCode = $ color -> getXTermCode ( ) ; $ this -> RGB = $ color -> getRGB ( ) ; $ this -> ANSICode = $ color -> getANSICode ( ) ; } else if ( is_string (...
The variety of ways to set a color
51,869
public function generateColorCoding ( $ mode , $ isFill = false ) { $ codes = "" ; if ( $ this -> isValid ( ) ) { $ mode = new Mode ( $ mode ) ; $ base = 0 ; if ( $ isFill ) { $ base = 10 ; } switch ( $ mode -> getMode ( ) ) { case Mode :: VT100 : $ codes = ( $ base + $ this -> getANSICode ( ) ) . "" ; break ; case Mod...
Generate a color coding based on the terminal type
51,870
public function next ( ) { if ( $ this -> isValid ( ) ) { $ colorNames = Colors :: getW3CIndex ( ) ; $ pos = array_search ( $ this -> name , $ colorNames ) ; if ( $ pos !== false ) { if ( $ pos === ( count ( $ colorNames ) - 1 ) ) { return $ colorNames [ 0 ] ; } else { return $ colorNames [ $ pos + 1 ] ; } } else { ret...
Return the next name on the main Colors name index
51,871
public function editSettings ( ) { $ this -> setTitleEditSettings ( ) ; $ this -> setBreadcrumbEditSettings ( ) ; $ this -> setData ( 'stores' , $ this -> store -> getList ( ) ) ; $ this -> setData ( 'credentials' , $ this -> getCredentialSettings ( ) ) ; $ this -> setData ( 'handlers' , $ this -> report_model -> getHa...
Route page callback Displays the module settings page
51,872
protected function validateGaProfileSettings ( ) { $ profiles = $ this -> getSubmitted ( 'ga_profile_id' , array ( ) ) ; if ( empty ( $ profiles ) ) { $ this -> setError ( 'ga_profile_id' , $ this -> text ( 'Profile ID is required' ) ) ; return false ; } $ stores = $ this -> store -> getList ( ) ; foreach ( $ profiles ...
Validates Google Analytics profiles
51,873
public function install ( ) { if ( ! isset ( $ this -> complement [ 'installation-files' ] ) ) { self :: $ errors [ ] = [ 'message' => $ this -> complement [ 'path' ] [ 'root' ] ] ; return false ; } $ this -> deleteDirectory ( ) ; $ this -> changeState ( ) ; $ installed = $ this -> installComplement ( $ this -> complem...
Complement installation handler .
51,874
public function remove ( ) { $ this -> setState ( 'uninstall' ) ; $ this -> changeState ( ) ; if ( ! $ this -> deleteDirectory ( ) ) { $ this -> setState ( 'uninstalled' ) ; } return true ; }
Delete complement .
51,875
private function deleteDirectory ( ) { $ path = $ this -> complement [ 'path' ] [ 'root' ] ; if ( ! $ this -> validateRoute ( $ path ) ) { return false ; } $ isUninstall = ( $ this -> getState ( ) === 'inactive' ) ; if ( ! File :: deleteDirRecursively ( $ path ) && $ isUninstall ) { $ type = self :: getType ( 'ucfirst'...
Delete complement directory .
51,876
private function installComplement ( $ complement , $ path , $ slug , $ root = true ) { $ path = ( $ root ) ? $ path : $ path . key ( $ complement ) . '/' ; if ( ! $ this -> validateRoute ( $ path ) ) { return false ; } if ( ! File :: createDir ( $ path ) ) { $ msg = "The directory exists or couldn't be created in: $pa...
Install complement .
51,877
private function saveRemoteFile ( $ fileUrl , $ filePath ) { if ( ! $ file = @ file_get_contents ( $ fileUrl ) ) { self :: $ errors [ ] = [ 'message' => 'Error to download file: ' . $ fileUrl ] ; return false ; } if ( ! @ file_put_contents ( $ filePath , $ file ) ) { self :: $ errors [ ] = [ 'message' => 'Failed to sav...
Save remote file .
51,878
public function boot ( ) { if ( ! is_dir ( Remember :: $ tokensDir ) ) { mkdir ( Remember :: $ tokensDir , 0777 , true ) ; } $ this -> hasTokens ( ) ; $ this -> configure ( ) ; $ this -> start ( ) ; }
Boot remember me component
51,879
public function hasTokens ( ) { if ( ! is_writable ( Remember :: $ tokensDir ) || ! is_dir ( Remember :: $ tokensDir ) ) { $ tokens = Remember :: $ tokensDir ; return $ this -> exception ( "'$tokens' does not exist or is not writable by the web server" ) ; } }
Check if the tokens directory exists or is writable
51,880
public function configure ( ) { $ tokenGenerator = new DefaultToken ( 94 , DefaultToken :: FORMAT_BASE64 ) ; $ expire = strtotime ( Remember :: $ expire , 0 ) ; $ cookie = new PHPCookie ( "application_session" , $ expire , "/" , "" , true , true ) ; Remember :: $ storage = new FileStorage ( Remember :: $ tokensDir ) ; ...
Configure remember me
51,881
public function start ( ) { $ rememberMe = Remember :: $ rememberMe ; $ loginResult = $ rememberMe -> login ( ) ; if ( $ loginResult -> isSuccess ( ) ) { $ _SESSION [ '_uas' ] = $ loginResult -> getCredential ( ) ; $ _SESSION [ 'remembered_by_cookie' ] = true ; return ; } if ( $ loginResult -> hasPossibleManipulation (...
Start remember me
51,882
public static function unwrap ( array $ input , $ default = null ) { if ( count ( $ input ) > 1 ) { return $ input ; } return ! empty ( $ input ) ? current ( $ input ) : $ default ; }
Unwraps a single item array into the item . If the array contains more than one item it will be returned as - is . A default value can be provided and will be used when an empty array is given .
51,883
public function resolveClass ( $ class ) { if ( ! is_string ( $ class ) ) throw new ResolverException ( "Class must be a string" ) ; if ( array_key_exists ( $ class , $ this -> classAlias ) ) try { return $ this -> resolve ( null , $ this -> classAlias [ $ class ] ) ; } catch ( ResolverException $ e ) { } foreach ( $ t...
Called the a class needs resolving . Each registered resolver will be called for this purpose the first to return non - false will succeed .
51,884
public static function additionalConfiguration ( $ extensionKey ) { $ extConf = self :: getSanitizedExtConf ( $ extensionKey ) ; if ( $ extConf [ 'cachingConfigEnable' ] == 1 ) { self :: handleCachingConfiguration ( $ extConf ) ; } }
Called from additionalConfiguration . php .
51,885
public function setResponseBody ( $ data ) { if ( ! is_string ( $ data ) ) { $ data = json_encode ( $ data , \ JSON_PRETTY_PRINT ) ; } $ this -> response -> getBody ( ) -> write ( $ data ) ; return $ this ; }
Set response body if is not string json_encode
51,886
protected function _curl ( $ data , $ url ) { if ( ! function_exists ( "curl_init" ) ) { return array ( "output" => NULL , "status" => - 1 ) ; } $ data_string = json_encode ( $ data ) ; $ curl = curl_init ( ) ; curl_setopt ( $ curl , CURLOPT_POST , true ) ; curl_setopt ( $ curl , CURLOPT_POSTFIELDS , $ data_string ) ; ...
request berupa CURL
51,887
public function setAction ( AbstractAction $ action ) : DateTime { $ this -> action = $ action ; $ this -> action -> setDateTime ( $ this ) ; return $ this ; }
Set strategy pattern action for modification array . Action callable object resieves whole array in container and return array ro replace .
51,888
public function add ( $ interval ) : DateTime { if ( $ interval instanceof DateInterval ) { $ this -> value -> add ( $ interval ) ; return $ this ; } $ i = $ this -> tryToCreateIntervalByDesignators ( $ interval ) ; if ( ! $ i ) { $ i = DateInterval :: createFromDateString ( $ interval ) ; } $ this -> value -> add ( $ ...
Performs dates arithmetic .
51,889
public function getDateMonday ( $ format = 'Y-m-d' ) { $ weekDay = $ this -> format ( 'N' ) - 1 ; $ dateTime = clone $ this ; if ( $ weekDay ) { $ dateTime -> add ( sprintf ( '- %d days' , $ weekDay ) ) ; } if ( $ format ) { return $ dateTime -> format ( $ format ) ; } return $ dateTime ; }
Returns monday date .
51,890
public function unserialize ( $ serialized ) { $ serialized = @ unserialize ( $ serialized ) ; if ( ! is_array ( $ serialized ) ) { throw new \ InvalidArgumentException ( 'Invalid argument 1, arguments must be serialized of array.' , E_USER_ERROR ) ; } $ this -> replace ( $ serialized ) ; }
Un - serialize Magic Method
51,891
public function setup ( string $ host , string $ username , string $ password , string $ security , bool $ use_smtp = true ) : void { $ this -> use_smtp = $ use_smtp ; $ this -> email_host = $ host ; $ this -> email_username = $ username ; $ this -> email_password = $ password ; $ this -> email_security = $ security ; ...
Use this function when you use it in your own project
51,892
public function emvc_config ( ) : void { $ this -> use_smtp = USE_SMTP ; $ this -> email_host = EMAIL_HOST ; $ this -> email_username = EMAIL_USERNAME ; $ this -> email_password = EMAIL_PASSWORD ; $ this -> email_security = EMAIL_SECURITY ; }
Use this function when you use it in the EasyMVC framework
51,893
public function setTextMessage ( array $ to , string $ subject , string $ body , array $ attachment = null , array $ cc = null , array $ bcc = EMAIL_BCC ) : void { $ this -> email -> setFrom ( $ this -> from ) ; foreach ( $ to as $ value ) { $ this -> email -> addTo ( $ value ) ; } if ( $ cc != null ) { foreach ( $ cc ...
Prepare a plain text E - mail
51,894
public function sendMail ( ) : void { if ( $ this -> use_smtp ) { $ mailer = new SmtpMailer ( [ 'host' => $ this -> email_host , 'username' => $ this -> email_username , 'password' => $ this -> email_password , 'secure' => $ this -> email_security ] ) ; } else { $ mailer = new SendmailMailer ( ) ; } $ mailer -> send ( ...
Use this after your E - mail has been prepared
51,895
public function emvcRenderHtml ( string $ latteFile , array $ data ) : string { $ latte = new Engine ( ) ; $ latte -> setTempDirectory ( $ _SERVER [ 'DOCUMENT_ROOT' ] . BASE_URL . '/tmp/latte' ) ; return $ latte -> renderToString ( $ _SERVER [ 'DOCUMENT_ROOT' ] . BASE_URL . '/private/latte/' . $ latteFile , $ data ) ; ...
Use Latte for rendering HTML E - mails in the EasyMVC framework
51,896
public function renderHtml ( string $ latteFile , array $ data , string $ tempFolderLatte = '/tmp/latte' ) : string { $ latte = new Engine ( ) ; $ latte -> setTempDirectory ( $ tempFolderLatte ) ; return $ latte -> renderToString ( $ latteFile , $ data ) ; }
Use Latte for rendering HTML E - mails in your own project
51,897
public function labelSetFormat ( $ format , $ unit ) { $ this -> format = $ format ; $ this -> paperSize = $ this -> getFormatValue ( 'paper-size' ) ; $ this -> orientation = $ this -> getFormatValue ( 'orientation' ) ; $ this -> fontName = $ this -> getFormatValue ( 'font-name' ) ; $ this -> charSize = $ this -> getFo...
initialize label format settings .
51,898
public function addPdfLabel ( string $ text ) { if ( $ this -> countX == $ this -> xNumber ) { $ this -> AddPage ( ) ; $ this -> countX = 0 ; $ this -> countY = 0 ; } $ posX = $ this -> marginLeft + ( $ this -> countX * ( $ this -> width + $ this -> xSpace ) ) ; $ posY = $ this -> marginTop + ( $ this -> countY * ( $ t...
Print a label .
51,899
public static function arrayWalkRecursive ( array $ data , callable $ function ) { if ( ! is_array ( $ data ) ) { return call_user_func ( $ function , $ data ) ; } foreach ( $ data as $ k => & $ item ) { $ item = self :: arrayWalkRecursive ( $ data [ $ k ] , $ function ) ; } return $ data ; }
Array walk recursive