idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
7,500
protected function validateUUID ( $ uuid ) { $ validator = Yii :: createObject ( array_merge ( [ 'class' => UniqueValidator :: class , ] , $ this -> uniqueValidator ) ) ; $ model = clone $ this -> owner ; $ model -> clearErrors ( ) ; $ model -> { $ this -> attribute } = $ uuid ; $ validator -> validateAttribute ( $ model , $ this -> attribute ) ; return ! $ model -> hasErrors ( ) ; }
Checks if given uuid value is unique .
7,501
public function changeExtension ( $ rename ) { $ search = '' ; $ replace = '' ; if ( is_array ( $ rename ) ) { $ search = key ( $ rename ) ; $ replace = current ( $ rename ) ; } if ( is_string ( $ rename ) ) { $ search = pathinfo ( $ this -> outputPathname , PATHINFO_EXTENSION ) ; $ replace = $ rename ; } $ this -> outputPathname = preg_replace ( "#$search\$#" , $ replace , $ this -> outputPathname ) ; return $ this ; }
Change the extension of the output pathname .
7,502
public function getPasswordBrokerManager ( ) : ? PasswordBrokerManager { if ( ! $ this -> hasPasswordBrokerManager ( ) ) { $ this -> setPasswordBrokerManager ( $ this -> getDefaultPasswordBrokerManager ( ) ) ; } return $ this -> passwordBrokerManager ; }
Get password broker manager
7,503
public function insertAsset ( AssetAbstract $ asset , $ location ) { array_splice ( $ this -> assets , $ location , 0 , array ( $ asset ) ) ; return $ this ; }
This will insert an asset in to a specific location in the array and then shift the element keys .
7,504
public function readCell ( $ column , $ row , $ worksheetName = '' ) { return ( $ row >= $ this -> firstRow && $ row <= $ this -> lastRow && array_key_exists ( $ column , $ this -> range ) ) ; }
Should this cell be read?
7,505
public function select ( $ mNameId , $ aData , $ mDefault = null , $ sClass = null , $ iTabindex = null , $ bDisabled = false , $ bMultiple = false , $ sExtraHtml = null ) { self :: getNameAndId ( $ mNameId , $ sName , $ sId ) ; $ res = '<select name="' . $ sName . '"' ; $ res .= null === $ sId ? '' : ' id="' . $ sId . '"' ; $ res .= null === $ sClass ? '' : ' class="' . $ sClass . '"' ; $ res .= null === $ iTabindex ? '' : ' tabindex="' . $ iTabindex . '"' ; $ res .= $ bDisabled ? ' disabled="disabled"' : '' ; $ res .= $ bMultiple ? ' multiple="multiple"' : '' ; $ res .= $ sExtraHtml ; $ res .= '>' . PHP_EOL ; $ res .= self :: selectOptions ( $ aData , $ mDefault ) ; $ res .= '</select>' . PHP_EOL ; return $ res ; }
Retourne un champ de formulaire de type select .
7,506
public function checkbox ( $ mNameId , $ value , $ checked = '' , $ sClass = null , $ iTabindex = null , $ bDisabled = false , $ sExtraHtml = null ) { self :: getNameAndId ( $ mNameId , $ sName , $ sId ) ; $ res = '<input type="checkbox" name="' . $ sName . '" value="' . $ value . '"' ; $ res .= null === $ sId ? '' : ' id="' . $ sId . '"' ; $ res .= $ checked ? ' checked="checked"' : '' ; $ res .= null === $ sClass ? '' : ' class="' . $ sClass . '"' ; $ res .= null === $ iTabindex ? '' : ' tabindex="' . $ iTabindex . '"' ; $ res .= $ bDisabled ? ' disabled="disabled"' : '' ; $ res .= $ sExtraHtml ; $ res .= '>' . PHP_EOL ; return $ res ; }
Retourne un champ de formulaire de type checkbox .
7,507
public function text ( $ mNameId , $ size , $ max = null , $ sDefault = null , $ sClass = null , $ sPlaceholder = null , $ iTabindex = null , $ bDisabled = false , $ sExtraHtml = null ) { self :: getNameAndId ( $ mNameId , $ sName , $ sId ) ; $ res = '<input type="text" size="' . $ size . '" name="' . $ sName . '"' ; $ res .= null === $ sId ? '' : ' id="' . $ sId . '"' ; $ res .= null === $ max ? '' : ' maxlength="' . $ max . '"' ; $ res .= null === $ sDefault ? '' : ' value="' . $ sDefault . '"' ; $ res .= null === $ sClass ? '' : ' class="' . $ sClass . '"' ; $ res .= null === $ sPlaceholder ? '' : ' placeholder="' . $ sPlaceholder . '"' ; $ res .= null === $ iTabindex ? '' : ' tabindex="' . $ iTabindex . '"' ; $ res .= $ bDisabled ? ' disabled="disabled"' : '' ; $ res .= $ sExtraHtml ; $ res .= '>' ; return $ res ; }
Retourne un champ de formulaire de type text .
7,508
public function file ( $ mNameId , $ sDefault = null , $ sClass = null , $ iTabindex = null , $ bDisabled = false , $ sExtraHtml = null ) { self :: getNameAndId ( $ mNameId , $ sName , $ sId ) ; $ res = '<input type="file" name="' . $ sName . '"' ; $ res .= null === $ sId ? '' : ' id="' . $ sId . '"' ; $ res .= null === $ sDefault ? '' : ' value="' . $ sDefault . '"' ; $ res .= null === $ sClass ? '' : ' class="' . $ sClass . '"' ; $ res .= null === $ iTabindex ? '' : ' tabindex="' . $ iTabindex . '"' ; $ res .= $ bDisabled ? ' disabled="disabled"' : '' ; $ res .= $ sExtraHtml ; $ res .= ' />' ; return $ res ; }
Retourne un champ de formulaire de type file .
7,509
public function textarea ( $ mNameId , $ iCols = null , $ iRows = null , $ sDefault = null , $ sClass = null , $ sPlaceholder = null , $ iTabindex = null , $ bDisabled = false , $ sExtraHtml = null ) { self :: getNameAndId ( $ mNameId , $ sName , $ sId ) ; $ res = '<textarea' ; $ res .= null === $ iCols ? '' : ' cols="' . $ iCols . '"' ; $ res .= null === $ iRows ? '' : ' rows="' . $ iRows . '"' ; $ res .= ' name="' . $ sName . '"' ; $ res .= null === $ sId ? '' : ' id="' . $ sId . '"' ; $ res .= null === $ sPlaceholder ? '' : ' placeholder="' . $ sPlaceholder . '"' ; $ res .= null === $ iTabindex ? '' : ' tabindex="' . $ iTabindex . '"' ; $ res .= null === $ sClass ? '' : ' class="' . $ sClass . '"' ; $ res .= $ bDisabled ? ' disabled="disabled"' : '' ; $ res .= $ sExtraHtml . '>' ; $ res .= $ sDefault ; $ res .= '</textarea>' ; return $ res ; }
Retourne un champ de formulaire de type textarea .
7,510
public function hidden ( $ mNameId , $ value ) { self :: getNameAndId ( $ mNameId , $ sName , $ sId ) ; $ res = '<input type="hidden" name="' . $ sName . '" value="' . $ value . '" ' ; $ res .= null === $ sId ? '' : ' id="' . $ sId . '"' ; $ res .= '>' ; return $ res ; }
Retourne un champ de formulaire de type hidden .
7,511
public function filterByStreet ( $ street = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ street ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ street ) ) { $ street = str_replace ( '*' , '%' , $ street ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( CustomerPeer :: STREET , $ street , $ comparison ) ; }
Filter the query on the street column
7,512
public function filterByZip ( $ zip = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ zip ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ zip ) ) { $ zip = str_replace ( '*' , '%' , $ zip ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( CustomerPeer :: ZIP , $ zip , $ comparison ) ; }
Filter the query on the zip column
7,513
public function filterByCity ( $ city = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ city ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ city ) ) { $ city = str_replace ( '*' , '%' , $ city ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( CustomerPeer :: CITY , $ city , $ comparison ) ; }
Filter the query on the city column
7,514
public function filterByCountryId ( $ countryId = null , $ comparison = null ) { if ( is_array ( $ countryId ) ) { $ useMinMax = false ; if ( isset ( $ countryId [ 'min' ] ) ) { $ this -> addUsingAlias ( CustomerPeer :: COUNTRY_ID , $ countryId [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ countryId [ 'max' ] ) ) { $ this -> addUsingAlias ( CustomerPeer :: COUNTRY_ID , $ countryId [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( CustomerPeer :: COUNTRY_ID , $ countryId , $ comparison ) ; }
Filter the query on the country_id column
7,515
public function filterByFax ( $ fax = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ fax ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ fax ) ) { $ fax = str_replace ( '*' , '%' , $ fax ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( CustomerPeer :: FAX , $ fax , $ comparison ) ; }
Filter the query on the fax column
7,516
public function filterByEmail ( $ email = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ email ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ email ) ) { $ email = str_replace ( '*' , '%' , $ email ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( CustomerPeer :: EMAIL , $ email , $ comparison ) ; }
Filter the query on the email column
7,517
public function filterByLegalform ( $ legalform = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ legalform ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ legalform ) ) { $ legalform = str_replace ( '*' , '%' , $ legalform ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( CustomerPeer :: LEGALFORM , $ legalform , $ comparison ) ; }
Filter the query on the legalform column
7,518
public function filterByLogo ( $ logo = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ logo ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ logo ) ) { $ logo = str_replace ( '*' , '%' , $ logo ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( CustomerPeer :: LOGO , $ logo , $ comparison ) ; }
Filter the query on the logo column
7,519
public function filterByCreated ( $ created = null , $ comparison = null ) { if ( is_array ( $ created ) ) { $ useMinMax = false ; if ( isset ( $ created [ 'min' ] ) ) { $ this -> addUsingAlias ( CustomerPeer :: CREATED , $ created [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ created [ 'max' ] ) ) { $ this -> addUsingAlias ( CustomerPeer :: CREATED , $ created [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( CustomerPeer :: CREATED , $ created , $ comparison ) ; }
Filter the query on the created column
7,520
public function filterByNotes ( $ notes = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ notes ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ notes ) ) { $ notes = str_replace ( '*' , '%' , $ notes ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( CustomerPeer :: NOTES , $ notes , $ comparison ) ; }
Filter the query on the notes column
7,521
public function filterByCountry ( $ country , $ comparison = null ) { if ( $ country instanceof Country ) { return $ this -> addUsingAlias ( CustomerPeer :: COUNTRY_ID , $ country -> getId ( ) , $ comparison ) ; } elseif ( $ country instanceof PropelObjectCollection ) { if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } return $ this -> addUsingAlias ( CustomerPeer :: COUNTRY_ID , $ country -> toKeyValue ( 'PrimaryKey' , 'Id' ) , $ comparison ) ; } else { throw new PropelException ( 'filterByCountry() only accepts arguments of type Country or PropelCollection' ) ; } }
Filter the query by a related Country object
7,522
public function useCountryQuery ( $ relationAlias = null , $ joinType = Criteria :: INNER_JOIN ) { return $ this -> joinCountry ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'Country' , '\Slashworks\AppBundle\Model\CountryQuery' ) ; }
Use the Country relation Country object
7,523
public function useUserCustomerRelationQuery ( $ relationAlias = null , $ joinType = Criteria :: INNER_JOIN ) { return $ this -> joinUserCustomerRelation ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'UserCustomerRelation' , '\Slashworks\AppBundle\Model\UserCustomerRelationQuery' ) ; }
Use the UserCustomerRelation relation UserCustomerRelation object
7,524
protected function resolve ( $ name ) { $ config = $ this -> disks [ $ name ] ; if ( isset ( $ config [ 'class' ] ) ) { return Yii :: createObject ( $ config ) ; } else if ( isset ( $ config [ 'adapter' ] ) ) { $ driverMethod = 'create' . ucfirst ( $ config [ 'adapter' ] ) . 'Adapter' ; if ( method_exists ( $ this , $ driverMethod ) ) { return $ this -> { $ driverMethod } ( $ config ) ; } else { throw new InvalidArgumentException ( "Adapter [{$config['adapter']}] is not supported." ) ; } } else { throw new InvalidArgumentException ( "Wrong adapter configuration." ) ; } }
Resolve the given disk .
7,525
public function createLocalAdapter ( array $ config ) { $ permissions = $ config [ 'permissions' ] ?? [ ] ; $ root = Yii :: getAlias ( $ config [ 'root' ] ) ; $ links = ( $ config [ 'links' ] ?? null ) === 'skip' ? LocalAdapter :: SKIP_LINKS : LocalAdapter :: DISALLOW_LINKS ; return $ this -> adapt ( $ this -> createFlysystem ( new LocalAdapter ( $ root , LOCK_EX , $ links , $ permissions ) , $ config ) ) ; }
Create an instance of the local adapter .
7,526
public function createOssAdapter ( array $ config ) { $ root = $ config [ 'root' ] ?? null ; $ oss = new OssClient ( $ config [ 'access_id' ] , $ config [ 'access_secret' ] , $ config [ 'endpoint' ] , $ config [ 'isCName' ] ?? false , $ config [ 'securityToken' ] ?? null , $ config [ 'proxy' ] ?? null ) ; $ oss -> setTimeout ( $ config [ 'timeout' ] ?? 3600 ) ; $ oss -> setConnectTimeout ( $ config [ 'connectTimeout' ] ?? 10 ) ; $ oss -> setUseSSL ( $ config [ 'useSSL' ] ?? false ) ; return $ this -> adapt ( $ this -> createFlysystem ( new OssAdapter ( $ oss , $ config [ 'bucket' ] , $ root ) , $ config ) ) ; }
Create an instance of the oss driver .
7,527
protected function createView ( $ path ) { $ contents = $ this -> getViewContents ( ) ; file_put_contents ( $ path , $ contents ) ; $ this -> info ( 'View created successfully.' ) ; }
Generate the Blade view .
7,528
protected function makeDirectory ( $ path ) { $ dir = dirname ( $ path ) ; if ( ! file_exists ( $ dir ) ) { mkdir ( $ dir , 0777 , true ) ; } }
Create the directory for the view if it does not already exist .
7,529
public function getQueueingBus ( ) : ? QueueingDispatcher { if ( ! $ this -> hasQueueingBus ( ) ) { $ this -> setQueueingBus ( $ this -> getDefaultQueueingBus ( ) ) ; } return $ this -> queueingBus ; }
Get queueing bus
7,530
public function serialize ( TranslatableInterface $ translatable , $ targetLang ) { $ output = $ this -> beginExport ( $ translatable , $ targetLang ) ; $ output .= $ this -> exportTranslatable ( $ translatable , $ targetLang ) ; $ output .= $ this -> endExport ( ) ; return $ output ; }
Serializes a given translatable into an XLIFF file with the specified target language .
7,531
public function unserialize ( TranslatableInterface $ translatable , $ targetLang , $ xliff , $ callSetData = TRUE ) { if ( $ this -> validateImport ( $ translatable , $ targetLang , $ xliff ) ) { $ data = $ this -> import ( $ xliff ) ; if ( $ callSetData ) { $ translatable -> setData ( $ data , $ targetLang ) ; } return $ data ; } else { return array ( ) ; } }
Unserializes given XLIFF data ; before unserialization occurs the provided XLIFF is also validated against the provided translatable and target language .
7,532
public function beginExport ( TranslatableInterface $ translatable , $ targetLang ) { $ this -> openMemory ( ) ; $ this -> setIndent ( TRUE ) ; $ this -> setIndentString ( ' ' ) ; $ this -> startDocument ( '1.0' , 'UTF-8' ) ; $ this -> startElement ( 'xliff' ) ; $ this -> writeAttribute ( 'version' , '1.2' ) ; $ this -> writeAttribute ( 'xmlns:xlf' , 'urn:oasis:names:tc:xliff:document:1.2' ) ; $ this -> writeAttribute ( 'xmlns:xsi' , 'http://www.w3.org/2001/XMLSchema-instance' ) ; $ this -> writeAttribute ( 'xmlns:html' , 'http://www.w3.org/1999/xhtml' ) ; $ this -> writeAttribute ( 'xsi:schemaLocation' , 'urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-strict.xsd' ) ; $ this -> startElement ( 'file' ) ; $ this -> writeAttribute ( 'original' , 'xliff-core-1.2-strict.xsd' ) ; $ this -> writeAttribute ( 'source-language' , $ this -> sourceLang ) ; $ this -> writeAttribute ( 'target-language' , $ targetLang ) ; $ this -> writeAttribute ( 'datatype' , 'plaintext' ) ; $ this -> writeAttribute ( 'date' , date ( 'Y-m-d\Th:m:i\Z' ) ) ; $ this -> startElement ( 'header' ) ; $ this -> startElement ( 'phase-group' ) ; $ this -> startElement ( 'phase' ) ; $ this -> writeAttribute ( 'tool-id' , 'eggs-n-cereal' ) ; $ this -> writeAttribute ( 'phase-name' , 'extraction' ) ; $ this -> writeAttribute ( 'process-name' , 'extraction' ) ; $ this -> writeAttribute ( 'job-id' , $ translatable -> getIdentifier ( ) ) ; $ this -> endElement ( ) ; $ this -> endElement ( ) ; $ this -> startElement ( 'tool' ) ; $ this -> writeAttribute ( 'tool-id' , 'eggs-n-cereal' ) ; $ this -> writeAttribute ( 'tool-name' , 'Eggs-n-Cereal XLIFF Serializer' ) ; $ this -> endElement ( ) ; $ this -> endElement ( ) ; return $ this -> outputMemory ( ) . '<body>' ; }
Starts an export .
7,533
public function exportTranslatable ( TranslatableInterface $ translatable , $ targetLang ) { $ this -> openMemory ( ) ; $ this -> setIndent ( TRUE ) ; $ this -> setIndentString ( ' ' ) ; $ this -> startElement ( 'xlf:group' ) ; $ this -> writeAttribute ( 'id' , $ translatable -> getIdentifier ( ) ) ; $ this -> writeAttribute ( 'restype' , 'x-eggs-n-cereal-translatable' ) ; $ translatableData = $ translatable -> getData ( ) ; $ flattenedData = Data :: flattenData ( $ translatableData ) ; $ data = array_filter ( $ flattenedData , array ( 'EggsCereal\Utils\Data' , 'filterData' ) ) ; foreach ( $ data as $ key => $ element ) { $ this -> addTransUnit ( $ key , $ element , $ targetLang ) ; } $ this -> endElement ( ) ; return $ this -> outputMemory ( ) ; }
Adds a translatable item to the XML export .
7,534
protected function addTransUnit ( $ key , $ element , $ targetLang ) { $ this -> startElement ( 'xlf:group' ) ; $ this -> writeAttribute ( 'id' , $ key ) ; $ this -> writeAttribute ( 'resname' , $ key ) ; $ this -> writeAttribute ( 'restype' , 'x-eggs-n-cereal-field' ) ; $ list = get_html_translation_table ( HTML_ENTITIES ) ; $ namedTable = array ( ) ; foreach ( $ list as $ k => $ v ) { $ namedTable [ $ v ] = "&amp;" . str_replace ( '&' , '' , $ v ) ; } $ element [ '#text' ] = strtr ( $ element [ '#text' ] , $ namedTable ) ; try { $ converter = new Converter ( $ element [ '#text' ] , $ this -> sourceLang , $ targetLang ) ; if ( $ this -> logger ) { $ converter -> setLogger ( $ this -> logger ) ; } $ this -> writeRaw ( $ converter -> toXLIFF ( ) ) ; } catch ( \ Exception $ e ) { $ this -> startElement ( 'trans-unit' ) ; $ this -> writeAttribute ( 'id' , uniqid ( 'text-' ) ) ; $ this -> writeAttribute ( 'restype' , 'x-eggs-n-cereal-failure' ) ; $ this -> startElement ( 'source' ) ; $ this -> writeAttribute ( 'xml:lang' , $ this -> sourceLang ) ; $ this -> text ( $ element [ '#text' ] ) ; $ this -> endElement ( ) ; $ this -> startElement ( 'target' ) ; $ this -> writeAttribute ( 'xml:lang' , $ targetLang ) ; $ this -> text ( $ element [ '#text' ] ) ; $ this -> endElement ( ) ; $ this -> endElement ( ) ; } if ( isset ( $ element [ '#label' ] ) ) { $ this -> writeElement ( 'note' , $ element [ '#label' ] ) ; } $ this -> endElement ( ) ; }
Adds a single translation unit for a data element .
7,535
public function serializerSimplexmlLoadString ( $ xmlString ) { $ numericTable = array ( ) ; $ numericTable [ '&' ] = '&#38;' ; $ entBitmask = defined ( 'ENT_HTML5' ) ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES ; $ trans = get_html_translation_table ( HTML_ENTITIES , $ entBitmask ) ; foreach ( $ trans as $ k => $ v ) { $ numericTable [ $ v ] = "&#" . ord ( $ k ) . ";" ; } $ xmlString = strtr ( $ xmlString , $ numericTable ) ; return simplexml_load_string ( $ xmlString ) ; }
Converts xml to string and handles entity encoding .
7,536
public function validateImport ( TranslatableInterface $ translatable , $ targetLang , $ xmlString ) { $ xmlString = Converter :: filterXmlControlCharacters ( $ xmlString ) ; $ error = $ this -> errorStart ( ) ; $ xml = $ this -> serializerSimplexmlLoadString ( $ xmlString ) ; $ this -> errorStop ( $ error ) ; if ( ! $ xml ) { return FALSE ; } $ errorArgs = array ( '%lang' => $ targetLang , '%srclang' => $ this -> sourceLang , '%name' => $ translatable -> getLabel ( ) , '%id' => $ translatable -> getIdentifier ( ) , ) ; $ phase = $ xml -> xpath ( "//phase[@phase-name='extraction']" ) ; if ( $ phase ) { $ phase = reset ( $ phase ) ; } else { $ this -> log ( LogLevel :: ERROR , 'Phase missing from XML.' , $ errorArgs ) ; return FALSE ; } if ( ! isset ( $ phase [ 'job-id' ] ) || ( $ translatable -> getIdentifier ( ) != ( string ) $ phase [ 'job-id' ] ) ) { $ this -> log ( LogLevel :: ERROR , 'The project id is missing in the XML.' , $ errorArgs ) ; return FALSE ; } elseif ( $ translatable -> getIdentifier ( ) != ( string ) $ phase [ 'job-id' ] ) { $ this -> log ( LogLevel :: ERROR , 'The project id is invalid in the XML. Correct id: %id.' , $ errorArgs ) ; return FALSE ; } if ( ! isset ( $ xml -> file [ 'source-language' ] ) ) { $ this -> log ( LogLevel :: ERROR , 'The source language is missing in the XML.' , $ errorArgs ) ; return FALSE ; } elseif ( $ xml -> file [ 'source-language' ] != $ this -> sourceLang ) { $ this -> log ( LogLevel :: ERROR , 'The source language is invalid in the XML. Correct langcode: %srclang.' , $ errorArgs ) ; return FALSE ; } if ( ! isset ( $ xml -> file [ 'target-language' ] ) ) { $ this -> log ( LogLevel :: ERROR , 'The target language is missing in the XML.' , $ errorArgs ) ; return FALSE ; } elseif ( $ targetLang != Data :: normalizeLangcode ( $ xml -> file [ 'target-language' ] ) ) { $ errorArgs [ '%wrong' ] = $ xml -> file [ 'target-language' ] ; $ this -> log ( LogLevel :: ERROR , 'The target language %wrong is invalid in the XML. Correct langcode: %lang.' , $ errorArgs ) ; return FALSE ; } return TRUE ; }
Validates an import .
7,537
protected function errorStop ( $ use ) { foreach ( libxml_get_errors ( ) as $ error ) { switch ( $ error -> level ) { case LIBXML_ERR_WARNING : case LIBXML_ERR_ERROR : $ level = LogLevel :: WARNING ; break ; case LIBXML_ERR_FATAL : $ level = LogLevel :: ERROR ; break ; default : $ level = LogLevel :: INFO ; } $ this -> log ( $ level , '%error on line %num. Error code: %code.' , array ( '%error' => trim ( $ error -> message ) , '%num' => $ error -> line , '%code' => $ error -> code , ) ) ; } libxml_clear_errors ( ) ; libxml_use_internal_errors ( $ use ) ; }
Ends custom error handling .
7,538
public static function getValue ( $ array , $ key , $ default = null ) { if ( is_string ( $ key ) ) { $ keys = explode ( '.' , $ key ) ; foreach ( $ keys as $ key ) { if ( ! isset ( $ array [ $ key ] ) ) { return $ default ; } $ array = & $ array [ $ key ] ; } return $ array ; } elseif ( is_null ( $ key ) ) { return $ array ; } return null ; }
Get value of path default value if path doesn t exist or all data
7,539
public function addOption ( OptionInterface $ option ) { if ( ! $ this -> hasOption ( $ option ) ) { $ this -> options -> add ( $ option ) ; } return $ this ; }
Add a given option
7,540
public function removeOption ( OptionInterface $ option ) { if ( $ this -> hasOption ( $ option ) ) { $ this -> options -> removeElement ( $ option ) ; } return $ this ; }
Remove a given option
7,541
public function getContent ( $ rowResult ) { if ( $ this -> callManager ( $ rowResult ) === false ) { return '' ; } return $ this -> builder -> render ( $ this -> template ) ; }
Get column content
7,542
public function setManager ( Closure $ manager ) { if ( ! is_callable ( $ manager ) ) { throw new Exception ( 'Manager must be callable.' ) ; } $ this -> manager = $ manager ; return $ this ; }
Set action manager
7,543
protected function render ( $ template , $ data = [ ] , $ status = 200 ) { $ rendered = View :: render ( $ template , $ data ) ; $ this -> response -> getBody ( ) -> write ( $ rendered ) ; return $ this -> getResponse ( ) -> withStatus ( $ status ) -> withHeader ( 'Content-Type' , 'text/html; charset=utf-8' ) ; }
Render a view template with optional data
7,544
protected function redirect ( $ url , $ status = 302 ) { return $ this -> getResponse ( ) -> withStatus ( $ status ) -> withHeader ( 'Location' , ( string ) $ url ) ; }
Redirect to URL with optional status
7,545
public function routerError ( $ error = null , $ subject = null ) { switch ( $ error ) { case Router :: ERR_NOT_FOUND : $ status = 404 ; $ template = 'router/error404' ; break ; case Router :: ERR_BAD_METHOD : $ status = 405 ; $ template = 'router/error405' ; break ; case Router :: ERR_MISSING_CONTROLLER : case Router :: ERR_MISSING_ACTION : default : $ status = 500 ; $ template = 'router/error' ; break ; } return $ this -> render ( $ template , compact ( 'error' , 'subject' ) , $ status ) ; }
Router Error Action
7,546
public function setRequest ( Request $ request ) { $ this -> request = $ request ; $ parsedBody = $ this -> request -> getParsedBody ( ) ; if ( ! empty ( $ parsedBody ) ) { if ( is_array ( $ parsedBody ) ) { $ this -> data = array_map ( 'trim' , ( array ) $ parsedBody ) ; } else { $ this -> data = $ parsedBody ; } } return $ this ; }
Assign a request object
7,547
public function setStyle3dId ( $ style3dId ) { $ this -> style3dId = ( string ) $ style3dId ; $ this -> style3d = null ; return $ this ; }
Set the Style3d id
7,548
public function setStyle3d ( Style3d $ style3d ) { $ this -> style3dId = null ; $ this -> style3d = $ style3d ; return $ this ; }
Set the Style3d
7,549
protected function RetrievePropertyValueFromData ( string $ property ) { $ isNullable = in_array ( $ property , static :: DaftObjectNullableProperties ( ) , DefinitionAssistant :: IN_ARRAY_STRICT_MODE ) ; if ( ! array_key_exists ( $ property , $ this -> data ) && ! $ isNullable ) { throw Exceptions \ Factory :: PropertyNotNullableException ( static :: class , $ property ) ; } elseif ( $ isNullable ) { return $ this -> data [ $ property ] ?? null ; } return $ this -> data [ $ property ] ; }
Retrieve a property from data .
7,550
public function pluck ( $ key_for_value , $ key_for_key = null ) { $ map = new Map ; $ this -> walk ( function ( $ v ) use ( $ key_for_value , $ key_for_key , $ map ) { if ( null === $ key_for_key ) { $ key = null ; } else if ( $ v -> has ( $ key_for_key ) ) { $ key = $ v -> get ( $ key_for_key ) ; } else { throw new \ OutOfBoundsException ( ) ; } if ( $ v -> has ( $ key_for_value ) ) { $ map [ $ key ] = $ v -> get ( $ key_for_value ) ; } else { throw new \ OutOfBoundsException ( ) ; } } ) ; return $ map ; }
Create a new map by pulling the given key out of all contained maps .
7,551
public function createService ( ServiceLocatorInterface $ serviceLocator ) { $ config = $ serviceLocator -> get ( 'Config' ) ; ErrorHandler :: start ( ) ; $ compiledInstantiators = include $ config [ 'ocra_di_compiler' ] [ 'compiled_di_instantiator_filename' ] ; ErrorHandler :: stop ( ) ; if ( ! is_array ( $ compiledInstantiators ) ) { $ di = $ this -> createDi ( $ config ) ; $ this -> compileDi ( $ di , $ config ) ; $ this -> getDiDefinitions ( $ config , $ di ) ; $ compiledInstantiators = include $ config [ 'ocra_di_compiler' ] [ 'compiled_di_instantiator_filename' ] ; } $ di = new CompiledInstantiatorsDi ( ) ; $ this -> configureDi ( $ di , $ config ) ; $ di -> setCompiledInstantiators ( $ compiledInstantiators ) ; $ this -> registerAbstractFactory ( $ serviceLocator , $ di ) ; return $ di ; }
Generates a compiled Di proxy to be used as a replacement for \ Zend \ Di \ Di
7,552
public static function flatten ( array $ array , $ prefix = '' , $ join = '.' ) { $ flat = array ( ) ; foreach ( $ array as $ key => $ value ) { $ key = $ prefix ? $ prefix . $ join . $ key : $ key ; if ( is_array ( $ value ) ) { $ flat = array_merge ( $ flat , self :: flatten ( $ value , $ key , $ join ) ) ; } else { $ flat [ $ key ] = $ value ; } } return $ flat ; }
Flattens an associative array .
7,553
protected function doInit ( ) { if ( $ this -> loadWith === self :: JAVASCRIPT ) { jQuery :: widget ( $ this -> html , $ this -> widgetName , ( array ) $ this -> widgetOptions ) ; } else { $ this -> html -> setAttribute ( 'data-widget' , $ this -> widgetName ) -> setAttribute ( 'data-widget-options' , $ this -> getJSONConverter ( ) -> stringify ( ( object ) $ this -> widgetOptions ) ) -> addClass ( 'widget-not-initialized' ) ; } }
Initialisiert das Widget des objektes
7,554
public function onUpdatedProposeUpdateTask ( ) { $ task = $ this -> em -> getRepository ( 'AnimeDbAppBundle:Task' ) -> findOneBy ( [ 'command' => 'animedb:propose-update' ] ) ; $ next_run = new \ DateTime ( ) ; $ next_run -> modify ( sprintf ( '+%s seconds 01:00:00' , ProposeUpdateCommand :: INERVAL_UPDATE ) ) ; $ this -> em -> persist ( $ task -> setNextRun ( $ next_run ) ) ; $ this -> em -> flush ( ) ; }
Update next run date for the propose update task .
7,555
public function setProviders ( $ providers ) { $ array = Parser :: map ( $ providers ) ; if ( empty ( $ array [ 'required' ] ) === false ) { $ this -> requiredProviders = implode ( ',' , $ array [ 'required' ] ) ; } if ( empty ( $ array [ 'hidden' ] ) === false ) { $ this -> hiddenProviders = implode ( ',' , $ array [ 'hidden' ] ) ; } return $ this ; }
Allows you to add authentication providers in the list of available .
7,556
public function setFields ( $ fields ) { if ( empty ( $ fields ) === false ) { if ( is_array ( $ fields ) === true ) { $ this -> requiredFields = implode ( ',' , $ fields ) ; } else { $ this -> requiredFields = $ fields ; } } return $ this ; }
Allows you to add to the list of fields requested for the provider s authorization .
7,557
public function setOptional ( $ fields ) { if ( empty ( $ fields ) === false ) { if ( is_array ( $ fields ) === true ) { $ this -> optionalFields = implode ( ',' , $ fields ) ; } else { $ this -> optionalFields = $ fields ; } } return $ this ; }
Allows you to add to the list of optionals fields .
7,558
public function setType ( $ type ) { if ( is_array ( $ type ) === true ) { $ type = $ type [ key ( $ type ) ] ; } $ this -> types = array_flip ( $ this -> types ) ; if ( isset ( $ this -> types [ $ type ] ) === true ) { $ this -> widget = $ type ; } return $ this ; }
Lets you specify the widget type . Must match the variable types
7,559
public function setUrl ( $ url = '' ) { if ( is_array ( $ url ) === true ) { $ url = $ url [ key ( $ url ) ] ; } $ request = new Request ( ) ; if ( empty ( $ url ) === true ) { $ this -> url = $ request -> getScheme ( ) . '://' . $ request -> getHttpHost ( ) . ( new Router ( ) ) -> getRewriteUri ( ) ; } else { $ this -> url = $ request -> getScheme ( ) . '://' . $ request -> getHttpHost ( ) . $ url ; } return $ this ; }
Lets you specify the callback url to redirect to when authorizing the page is reloaded . If the url is not specified and is used to redirect the authorization the authorization after the current page just updated
7,560
private function destroyUserData ( ) { if ( is_array ( $ this -> user ) === true && isset ( $ this -> user [ "error" ] ) === true ) { $ this -> user = false ; return true ; } return false ; }
Destroy user data
7,561
public function getToken ( ) { $ request = new Request ( ) ; if ( $ request -> isPost ( ) === true ) { $ this -> token = $ request -> getPost ( 'token' , null , false ) ; } else { $ this -> token = $ request -> getQuery ( 'token' , null , false ) ; } return $ this -> token ; }
Reads the parameters passed to the script and selects the authorization key ULogin
7,562
public function getUser ( ) { $ this -> destroyUserData ( ) ; if ( $ this -> user === false ) { $ url = 'http://ulogin.ru/token.php?token=' . $ this -> getToken ( ) . '&host=' . ( new Request ( ) ) -> getHttpHost ( ) ; $ content = file_get_contents ( $ url ) ; $ this -> user = json_decode ( $ content , true ) ; if ( $ this -> destroyUserData ( ) === true ) { $ this -> logout ( ) ; } } return $ this -> user ; }
Returns an associative array with the data about the user . Fields array described in the method setFields
7,563
public function isAuthorised ( ) { if ( is_array ( $ this -> user ) === true && isset ( $ this -> user [ 'error' ] ) === false ) { return true ; } return $ this -> getUser ( ) ; }
Checks whether logon
7,564
public function getForm ( ) { $ view = new View ( ) ; return $ view -> render ( __DIR__ . '/../views/ulogin' , [ 'widget' => $ this -> widget , 'fields' => $ this -> requiredFields , 'optional' => $ this -> optionalFields , 'providers' => $ this -> requiredProviders , 'hidden' => $ this -> hiddenProviders , 'url' => $ this -> url ] ) ; }
Returns the html - form widget
7,565
public function setOverwrite ( $ state = false ) { $ tmp = $ this -> overwrite ; if ( $ state ) { $ this -> overwrite = true ; } else { $ this -> overwrite = false ; } return $ tmp ; }
Set the allow overwrite switch
7,566
public function setUpgrade ( $ state = false ) { $ tmp = $ this -> upgrade ; if ( $ state ) { $ this -> upgrade = true ; } else { $ this -> upgrade = false ; } return $ tmp ; }
Set the upgrade switch
7,567
public function getPath ( $ name , $ default = null ) { return ( ! empty ( $ this -> paths [ $ name ] ) ) ? $ this -> paths [ $ name ] : $ default ; }
Get an installer path by name
7,568
public function abort ( $ msg = null , $ type = null ) { $ retval = true ; $ step = array_pop ( $ this -> stepStack ) ; if ( $ msg ) { $ this -> log ( LogLevel :: WARNING , $ msg ) ; } while ( $ step != null ) { switch ( $ step [ 'type' ] ) { case 'file' : $ stepval = File :: delete ( $ step [ 'path' ] ) ; break ; case 'folder' : $ stepval = File :: delete ( $ step [ 'path' ] ) ; break ; default : $ stepval = false ; break ; } if ( $ stepval === false ) { $ retval = false ; } $ step = array_pop ( $ this -> stepStack ) ; } $ debug = Config :: get ( ) -> get ( 'debug' ) ; if ( $ debug ) { throw new RuntimeException ( 'Installation unexpectedly terminated: ' . $ msg , 500 ) ; } return $ retval ; }
Installation abort method
7,569
public function parseFiles ( SimpleXMLElement $ element , $ cid = 0 , $ oldFiles = null , $ oldMD5 = null ) { if ( ! $ element || ! $ element -> children ( ) -> count ( ) ) { return 0 ; } $ copyfiles = array ( ) ; $ pathname = 'extension_root' ; $ destination = $ this -> getPath ( $ pathname ) ; $ folder = ( string ) $ element -> attributes ( ) -> folder ; if ( $ folder && file_exists ( $ this -> getPath ( 'source' ) . '/' . $ folder ) ) { $ source = $ this -> getPath ( 'source' ) . '/' . $ folder ; } else { $ source = $ this -> getPath ( 'source' ) ; } if ( $ oldFiles && ( $ oldFiles instanceof SimpleXMLElement ) ) { $ oldEntries = $ oldFiles -> children ( ) ; if ( $ oldEntries -> count ( ) ) { $ deletions = $ this -> findDeletedFiles ( $ oldEntries , $ element -> children ( ) ) ; foreach ( $ deletions [ 'folders' ] as $ deleted_folder ) { Folder :: delete ( $ destination . '/' . $ deleted_folder ) ; } foreach ( $ deletions [ 'files' ] as $ deleted_file ) { File :: delete ( $ destination . '/' . $ deleted_file ) ; } } } $ path = array ( ) ; if ( file_exists ( $ source . '/MD5SUMS' ) ) { $ path [ 'src' ] = $ source . '/MD5SUMS' ; $ path [ 'dest' ] = $ destination . '/MD5SUMS' ; $ path [ 'type' ] = 'file' ; $ copyfiles [ ] = $ path ; } foreach ( $ element -> children ( ) as $ file ) { $ path [ 'src' ] = $ source . '/' . $ file ; $ path [ 'dest' ] = $ destination . '/' . $ file ; $ path [ 'type' ] = ( $ file -> getName ( ) == 'folder' ) ? 'folder' : 'file' ; if ( basename ( $ path [ 'dest' ] ) != $ path [ 'dest' ] ) { $ newdir = dirname ( $ path [ 'dest' ] ) ; if ( ! Folder :: create ( $ newdir ) ) { $ this -> log ( LogLevel :: WARNING , Text :: sprintf ( 'JLIB_INSTALLER_ERROR_CREATE_DIRECTORY' , $ newdir ) ) ; return false ; } } $ copyfiles [ ] = $ path ; } return $ this -> copyFiles ( $ copyfiles ) ; }
Method to parse through a files element of the installation manifest and take appropriate action .
7,570
public function send ( Parameters $ params ) { $ this -> client -> setUri ( ReCaptcha :: VERIFY_SERVER ) ; $ this -> client -> setRawBody ( $ params -> toQueryString ( ) ) ; $ this -> client -> setEncType ( 'application/x-www-form-urlencoded' ) ; $ result = $ this -> client -> setMethod ( 'POST' ) -> send ( ) ; return $ result ? $ result -> getBody ( ) : null ; }
Submit ReCaptcha API request return response body .
7,571
public function operate ( Expression $ left , Expression $ right ) { $ typeSpec = self :: $ opTypes [ $ this -> name ] ; $ leftType = self :: $ typeSpecMap [ $ typeSpec [ 0 ] ] ; $ rightType = self :: $ typeSpecMap [ $ typeSpec [ 1 ] ] ; $ resultType = self :: $ typeSpecMap [ $ typeSpec [ 2 ] ] ; $ start = min ( $ this -> pos , $ left -> pos , $ right -> pos ) ; $ end = max ( $ this -> end , $ left -> end , $ right -> end ) ; $ length = $ end - $ start ; $ newExpr = new Expression ( $ this -> parser , $ resultType , "{$left->rpn} {$right->rpn} {$this->name}" , $ start , $ length ) ; if ( ! $ left -> isType ( $ leftType ) ) { $ newExpr -> error ( "invalid type for left operand: expected $leftType, got {$left->type}" ) ; } if ( ! $ right -> isType ( $ rightType ) ) { $ newExpr -> error ( "invalid type for right operand: expected $rightType, got {$right->type}" ) ; } return $ newExpr ; }
Compute the operation
7,572
public function addPageControl ( Control $ pageControl , $ pageNumber = null ) { if ( $ pageNumber === null ) { $ pageNumber = count ( $ this -> pages ) + 1 ; } $ page = new PagingPage ( $ pageControl , $ pageNumber ) ; return $ this -> addPage ( $ page ) ; }
Add a new Page Control
7,573
public function addPage ( PagingPage $ page ) { if ( ! in_array ( $ page , $ this -> pages , true ) ) { array_push ( $ this -> pages , $ page ) ; } return $ this ; }
Add a new Page
7,574
public function setPages ( array $ pages ) { $ this -> pages = array ( ) ; foreach ( $ pages as $ page ) { $ this -> addPage ( $ page ) ; } return $ this ; }
Add new Pages
7,575
public function addButtonControl ( Control $ buttonControl , $ browseAction = null ) { if ( $ browseAction === null ) { $ buttonCount = count ( $ this -> buttons ) ; if ( $ buttonCount % 2 === 0 ) { $ browseAction = $ buttonCount / 2 + 1 ; } else { $ browseAction = $ buttonCount / - 2 - 1 ; } } $ button = new PagingButton ( $ buttonControl , $ browseAction ) ; return $ this -> addButton ( $ button ) ; }
Add a new Button Control to browse through the Pages
7,576
public function addButton ( PagingButton $ button ) { if ( ! in_array ( $ button , $ this -> buttons , true ) ) { array_push ( $ this -> buttons , $ button ) ; } return $ this ; }
Add a new Button to browse through Pages
7,577
public function setButtons ( array $ buttons ) { $ this -> buttons = array ( ) ; foreach ( $ buttons as $ button ) { $ this -> addButton ( $ button ) ; } return $ this ; }
Set the Paging Buttons
7,578
protected function getMinPage ( ) { $ minPageNumber = null ; $ minPage = null ; foreach ( $ this -> pages as $ page ) { $ pageNumber = $ page -> getPageNumber ( ) ; if ( $ minPageNumber === null || $ pageNumber < $ minPageNumber ) { $ minPageNumber = $ pageNumber ; $ minPage = $ page ; } } return $ minPage ; }
Get the minimum Page
7,579
protected function getMaxPage ( ) { $ maxPageNumber = null ; $ maxPage = null ; foreach ( $ this -> pages as $ page ) { $ pageNumber = $ page -> getPageNumber ( ) ; if ( $ maxPageNumber === null || $ pageNumber > $ maxPageNumber ) { $ maxPageNumber = $ pageNumber ; $ maxPage = $ page ; } } return $ maxPage ; }
Get the maximum Page
7,580
protected function getPagesArrayText ( ) { if ( empty ( $ this -> pages ) ) { return Builder :: getArray ( array ( 0 => '' ) , true ) ; } $ pages = array ( ) ; foreach ( $ this -> pages as $ page ) { $ pages [ $ page -> getPageNumber ( ) ] = $ page -> getControl ( ) -> getId ( ) ; } return Builder :: getArray ( $ pages , true ) ; }
Build the array text for the Pages
7,581
protected function getPageButtonsArrayText ( ) { if ( empty ( $ this -> buttons ) ) { return Builder :: getArray ( array ( '' => 0 ) , true ) ; } $ pageButtons = array ( ) ; foreach ( $ this -> buttons as $ pageButton ) { $ pageButtons [ $ pageButton -> getControl ( ) -> getId ( ) ] = $ pageButton -> getPagingCount ( ) ; } return Builder :: getArray ( $ pageButtons , true ) ; }
Build the array text for the Page Buttons
7,582
public static function factory ( string $ name , $ options = null ) : RepositoryInterface { try { $ className = sprintf ( '%s\%sRepository' , self :: getNamespace ( ) , ucfirst ( strtolower ( $ name ) ) ) ; $ reflectionClass = new \ ReflectionClass ( $ className ) ; if ( is_null ( $ options ) ) { return $ reflectionClass -> newInstance ( ) ; } return $ reflectionClass -> newInstance ( $ options ) ; } catch ( \ ReflectionException $ ex ) { throw new InvalidRepositoryException ( sprintf ( 'The %s repository does not exist.' , $ name ) ) ; } }
Returns the desired repository using the provided data .
7,583
public function toObject ( ) { $ obj = new stdClass ( ) ; if ( ! empty ( $ this -> attributes ) ) { foreach ( $ this -> attributes as $ key => $ value ) { $ obj -> $ key = $ value ; } } return $ obj ; }
Convert this class to a standard object .
7,584
public function calculate ( ColorJizz $ foreground , ColorJizz $ background ) { $ fgLuma = $ this -> relativeLuminosity ( $ foreground -> toRGB ( ) ) ; $ bgLuma = $ this -> relativeLuminosity ( $ background -> toRGB ( ) ) ; if ( $ fgLuma > $ bgLuma ) { return ( $ fgLuma + 0.05 ) / ( $ bgLuma + 0.05 ) ; } else { return ( $ bgLuma + 0.05 ) / ( $ fgLuma + 0.05 ) ; } }
returns the contrast ratio between foreground and background color .
7,585
public static function arrayResolve ( array $ data ) { $ array = [ ] ; foreach ( $ data as $ provider => $ bool ) { if ( $ bool === true ) { $ array [ 'required' ] [ ] = $ provider ; } else { $ array [ 'hidden' ] [ ] = $ provider ; } } return $ array ; }
Resolve array data as providers
7,586
private static function isDelim ( $ provider , $ delimiter = '=' ) { if ( mb_strpos ( $ provider , $ delimiter ) !== false ) { $ res = explode ( '=' , $ provider ) ; return $ res ; } return false ; }
Check if data has delimiter
7,587
public static function encodeParams ( string $ html , array $ variables = [ ] ) : string { $ normalizedVariables = [ ] ; if ( is_array ( $ variables ) ) { foreach ( $ variables as $ key => $ value ) { $ key = '{' . trim ( $ key , '{}' ) . '}' ; $ normalizedVariables [ $ key ] = static :: encode ( $ value ) ; } $ html = strtr ( $ html , $ normalizedVariables ) ; } return $ html ; }
Will take an HTML string and an associative array of key = > value pairs HTML encode the values and swap them back into the original string using the keys as tokens .
7,588
public function setRed ( float $ red , float $ scale = 1. ) { $ this -> red = $ this -> setComponent ( $ red , $ scale ) ; return $ this ; }
Sets the red component of the color .
7,589
public function setGreen ( float $ green , float $ scale = 1. ) { $ this -> green = $ this -> setComponent ( $ green , $ scale ) ; return $ this ; }
Sets the green component of the color .
7,590
public function setBlue ( float $ blue , float $ scale = 1. ) { $ this -> blue = $ this -> setComponent ( $ blue , $ scale ) ; return $ this ; }
Sets the blue component of the color .
7,591
public function setAlpha ( float $ alpha , float $ scale = 1. ) { $ this -> alpha = $ this -> setComponent ( $ alpha , $ scale ) ; return $ this ; }
Sets the alpha component of the color .
7,592
protected function setComponent ( float $ value , float $ scale ) : float { return ( $ scale < 0 ) ? ( 1 - $ value / - $ scale ) : ( $ value / $ scale ) ; }
Calculates the value to set a component .
7,593
protected function getComponent ( float $ value , float $ scale ) : float { return ( $ scale < 0 ) ? ( ( 1 - $ value ) * - $ scale ) : ( $ value * $ scale ) ; }
Calculates the value to get a component .
7,594
public function getNotificationDispatcher ( ) : ? Dispatcher { if ( ! $ this -> hasNotificationDispatcher ( ) ) { $ this -> setNotificationDispatcher ( $ this -> getDefaultNotificationDispatcher ( ) ) ; } return $ this -> notificationDispatcher ; }
Get notification dispatcher
7,595
public static function _init ( ) { static :: $ path_offset = ClanCats :: $ config -> get ( 'url.path' , '/' ) ; if ( empty ( static :: $ path_offset ) ) { static :: $ path_offset = '/' ; } if ( substr ( static :: $ path_offset , - 1 ) != '/' ) { static :: $ path_offset .= '/' ; } static :: $ parameter_provider = array ( 'fingerprint' => function ( ) { return array ( ClanCats :: $ config -> get ( 'session.default_fingerprint_parameter' ) => fingerprint ( ) ) ; } , 'back' => function ( ) { $ params = CCIn :: $ _instance -> GET ; unset ( $ params [ 'next' ] ) ; return array ( 'next' => CCUrl :: current ( $ params ) ) ; } , ) ; }
static CCUrl initialisation
7,596
public static function to ( $ uri = '' , $ params = array ( ) , $ retain = false ) { if ( $ uri === '/' ) { $ uri = '' ; } if ( substr ( $ uri , 0 , 1 ) == '@' ) { return static :: alias ( substr ( $ uri , 1 ) , $ params , $ retain ) ; } if ( strpos ( $ uri , '?' ) !== false ) { $ parts = explode ( '?' , $ uri ) ; $ uri = $ parts [ 0 ] ; if ( isset ( $ parts [ 1 ] ) ) { parse_str ( $ parts [ 1 ] , $ old_params ) ; $ params = array_merge ( $ old_params , $ params ) ; } } if ( strpos ( $ uri , '://' ) === false && substr ( $ uri , 0 , 1 ) !== '/' ) { $ uri = static :: $ path_offset . $ uri ; } foreach ( $ params as $ key => $ value ) { if ( is_numeric ( $ key ) && is_string ( $ value ) && $ value [ 0 ] === ':' ) { $ param_provider_key = substr ( $ value , 1 ) ; unset ( $ params [ $ key ] ) ; if ( array_key_exists ( $ param_provider_key , static :: $ parameter_provider ) ) { $ params = $ params + call_user_func ( static :: $ parameter_provider [ $ param_provider_key ] ) ; } } if ( ! is_array ( $ value ) ) { $ uri = str_replace ( ':' . $ key , $ value , $ uri , $ count ) ; if ( $ count > 0 ) { unset ( $ params [ $ key ] ) ; } } } if ( $ retain ) { $ params = array_merge ( CCIn :: $ _instance -> GET , $ params ) ; } if ( ! empty ( $ params ) ) { $ uri .= '?' . http_build_query ( $ params ) ; } return $ uri ; }
Generate an url
7,597
public static function alias ( $ alias , $ params = array ( ) , $ retain = false ) { $ route_params = array ( ) ; $ suffix = '' ; if ( strpos ( $ alias , '/' ) !== false && $ alias !== '/' ) { list ( $ alias , $ suffix ) = explode ( '/' , $ alias ) ; $ suffix = '/' . $ suffix ; } foreach ( $ params as $ key => $ value ) { if ( is_int ( $ key ) ) { $ route_params [ ] = $ value ; unset ( $ params [ $ key ] ) ; } } return CCUrl :: to ( CCRouter :: alias ( $ alias , $ route_params ) . $ suffix , $ params , $ retain ) ; }
Create an URL based on an router alias
7,598
public static function full ( $ uri = '' , $ params = array ( ) , $ retain = false ) { return CCIn :: protocol ( ) . '://' . CCIn :: host ( ) . static :: to ( $ uri , $ params , $ retain ) ; }
Create the full url including protocol and hostname
7,599
public static function secure ( $ uri = '' , $ params = array ( ) , $ retain = false ) { return 'https://' . CCIn :: host ( ) . static :: to ( $ uri , $ params , $ retain ) ; }
Create the url and force the https protocol