idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
53,900
|
protected function createStackDriver ( ) { $ determiners = ( new Collection ( ( array ) $ this -> app [ 'config' ] [ 'localize-middleware' ] [ 'driver' ] ) ) -> filter ( function ( $ driver ) { return $ driver !== 'stack' ; } ) -> map ( function ( $ driver ) { return $ this -> driver ( $ driver ) -> setFallback ( null ) ; } ) ; return ( new Determiners \ Stack ( $ determiners ) ) -> setFallback ( $ this -> app [ 'config' ] [ 'app' ] [ 'fallback_locale' ] ) ; }
|
Get a stack determiner instance .
|
53,901
|
public function get ( $ key ) { $ env = $ this -> parseFile ( ) ; $ result = $ env -> filter ( function ( Collection $ value ) use ( $ key ) { return $ value -> first ( ) == $ key ; } ) -> first ( ) ; return $ result instanceof Collection ? $ result -> get ( 1 ) : $ result ; }
|
Get an entry from the . env file by key .
|
53,902
|
public function set ( $ key , $ value , $ linebreak = false ) { $ oldValue = $ this -> get ( $ key ) ; if ( ! preg_match ( '/\d/' , $ value ) || preg_match ( '/=/' , $ value ) ) { $ value = "\"$value\"" ; } $ new = $ linebreak ? "\n$key=$value" : "$key=$value" ; if ( ! is_null ( $ oldValue ) ) { return $ this -> replaceInFile ( "$key=$oldValue" , $ new ) ; } file_put_contents ( $ this -> getPath ( ) , "\n$new" , FILE_APPEND ) ; return $ this ; }
|
Set the value of the given key to the value supplied .
|
53,903
|
private function parseFile ( ) { $ contents = file_get_contents ( $ this -> getPath ( ) ) ; $ lines = new Collection ( explode ( "\n" , $ contents ) ) ; $ result = new Collection ( ) ; $ lines -> filter ( function ( $ value ) { return $ value ; } ) -> each ( function ( $ value ) use ( $ result ) { preg_match ( '/([a-zA-Z_-]+)\=(.+)/' , $ value , $ regexResult ) ; array_shift ( $ regexResult ) ; $ result -> push ( new Collection ( $ regexResult ) ) ; } ) ; return $ result ; }
|
Parse the . env file contents for easier handling .
|
53,904
|
public function replaceInFile ( $ old , $ new , $ append = 0 ) { $ contents = $ this -> previous ; $ replaceWith = preg_replace ( "~$old\n?~" , "$new\n" , $ contents ) ; file_put_contents ( $ this -> getPath ( ) , $ replaceWith , $ append ) ; return $ this ; }
|
Replace a part of the . env file .
|
53,905
|
public function revokePermissionTo ( $ permission ) { $ this -> permissions ( ) -> detach ( $ this -> getStoredPermission ( $ permission ) ) ; $ this -> forgetCachedPermissions ( ) ; return $ this ; }
|
Revoke the given permission .
|
53,906
|
public function determineLocale ( Request $ request ) { return $ request -> session ( ) -> get ( $ this -> sessionKey , $ this -> fallback ) ; }
|
Determine the locale from the session .
|
53,907
|
public function determineLocale ( Request $ request ) { $ locale = $ this -> determiners -> map ( function ( $ determiner ) use ( $ request ) { return $ determiner -> determineLocale ( $ request ) ; } ) -> filter ( ) -> first ( ) ; return $ locale ? : $ this -> fallback ; }
|
Determine the locale from the underlying determiner stack .
|
53,908
|
public function getLogsFromCurrentFile ( ) { if ( $ this -> currentFile === null ) { return [ ] ; } if ( File :: size ( $ this -> currentFile ) > $ this -> maxFileSize ) { return ; } $ datePattern = '\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}' ; $ pattern = "/\\[$datePattern\\].*/" ; $ fileContent = File :: get ( $ this -> currentFile ) ; preg_match_all ( $ pattern , $ fileContent , $ rows ) ; if ( ! is_array ( $ rows ) || count ( $ rows ) === 0 ) { return [ ] ; } $ rows = $ rows [ 0 ] ; $ logs = [ ] ; foreach ( $ rows as $ row ) { preg_match ( "/^\\[($datePattern)\\].*?(\\w+)\\." . '([A-Z]+): (.*?)( in .*?:[0-9]+)?$/' , $ row , $ matches ) ; if ( ! isset ( $ matches [ 4 ] ) ) { continue ; } $ level = Str :: lower ( $ matches [ 3 ] ) ; $ inFile = null ; if ( isset ( $ matches [ 5 ] ) ) { $ inFile = substr ( $ matches [ 5 ] , 4 ) ; } $ logs [ ] = ( object ) [ 'context' => $ matches [ 2 ] , 'level' => $ level , 'levelClass' => static :: $ levelsClasses [ $ level ] , 'levelImg' => static :: $ levelsImgs [ $ level ] , 'date' => $ matches [ 1 ] , 'text' => trim ( $ matches [ 4 ] ) , 'inFile' => $ inFile , ] ; } return array_reverse ( $ logs ) ; }
|
Returns logs from current file .
|
53,909
|
public function getRelativePathToCurrentDirectoryParent ( ) { if ( $ this -> baseDir === $ this -> currentDir ) { return DIRECTORY_SEPARATOR ; } $ path = realpath ( $ this -> currentDir . DIRECTORY_SEPARATOR . '..' ) ; return $ this -> getPathRelativeToBaseDir ( $ path ) ? : DIRECTORY_SEPARATOR ; }
|
Returns path to parent of current directory .
|
53,910
|
public function getParentDirectories ( ) { if ( $ this -> isCurrentDirectoryBase ( ) ) { return [ ] ; } $ currentDir = $ this -> currentDir ; $ dirs = [ ] ; do { $ dir = dirname ( $ currentDir ) ; $ dirs [ ] = $ this -> getPathRelativeToBaseDir ( $ dir ) ? : DIRECTORY_SEPARATOR ; $ currentDir = $ dir ; } while ( $ dir !== $ this -> baseDir ) ; return array_reverse ( $ dirs ) ; }
|
Returns parent directories of current directory .
|
53,911
|
public function offsetSet ( $ offset , $ value ) { $ this -> internArray [ $ offset ] = $ value ; return $ this -> _set ( $ this -> getAttributeName ( ) , $ this -> internArray ) ; }
|
Method setting value at offset
|
53,912
|
public function offsetUnset ( $ offset ) { if ( $ this -> offsetExists ( $ offset ) ) { unset ( $ this -> internArray [ $ offset ] ) ; $ this -> _set ( $ this -> getAttributeName ( ) , $ this -> internArray ) ; } return $ this ; }
|
Method unsetting value at offset
|
53,913
|
public function initInternArray ( $ array = [ ] , $ internCall = false ) { if ( is_array ( $ array ) && count ( $ array ) > 0 ) { $ this -> setInternArray ( $ array ) -> setInternArrayOffset ( 0 ) -> setInternArrayIsArray ( true ) ; } elseif ( ! $ internCall && property_exists ( $ this , $ this -> getAttributeName ( ) ) ) { $ this -> initInternArray ( $ this -> _get ( $ this -> getAttributeName ( ) ) , true ) ; } return $ this ; }
|
Method initiating internArray
|
53,914
|
public function getpdf ( $ html ) { $ testFilePath = "/../../../../../../app/dompdf_config.inc.php" ; if ( file_exists ( dirname ( __FILE__ ) . $ testFilePath ) ) { require_once ( dirname ( __FILE__ ) . $ testFilePath ) ; } else { require_once dirname ( __FILE__ ) . '/../DomPDF/dompdf_config.inc.php' ; } $ this -> pdf = new \ DOMPDF ( ) ; $ this -> pdf -> set_paper ( DOMPDF_DEFAULT_PAPER_SIZE ) ; $ this -> pdf -> load_html ( $ html ) ; $ this -> pdf -> render ( ) ; }
|
Render a pdf document
|
53,915
|
public function determineLocale ( Request $ request ) { return $ this -> hostMapping -> flip ( ) -> get ( $ request -> getHost ( ) , $ this -> fallback ) ; }
|
Determine the locale from the current host .
|
53,916
|
public static function getDefaultWsdlOptions ( ) { return [ self :: WSDL_AUTHENTICATION => null , self :: WSDL_CACHE_WSDL => WSDL_CACHE_NONE , self :: WSDL_CLASSMAP => null , self :: WSDL_COMPRESSION => null , self :: WSDL_CONNECTION_TIMEOUT => null , self :: WSDL_ENCODING => null , self :: WSDL_EXCEPTIONS => true , self :: WSDL_FEATURES => SOAP_SINGLE_ELEMENT_ARRAYS | SOAP_USE_XSI_ARRAY_TYPE , self :: WSDL_LOCAL_CERT => null , self :: WSDL_LOCATION => null , self :: WSDL_LOGIN => null , self :: WSDL_PASSPHRASE => null , self :: WSDL_PASSWORD => null , self :: WSDL_PROXY_HOST => null , self :: WSDL_PROXY_LOGIN => null , self :: WSDL_PROXY_PASSWORD => null , self :: WSDL_PROXY_PORT => null , self :: WSDL_SOAP_VERSION => null , self :: WSDL_SSL_METHOD => null , self :: WSDL_STREAM_CONTEXT => null , self :: WSDL_STYLE => null , self :: WSDL_TRACE => true , self :: WSDL_TYPEMAP => null , self :: WSDL_URL => null , self :: WSDL_URI => null , self :: WSDL_USE => null , self :: WSDL_USER_AGENT => null , ] ; }
|
Method returning all default options values
|
53,917
|
public function setLocation ( $ location ) { if ( $ this -> getSoapClient ( ) instanceof \ SoapClient ) { $ this -> getSoapClient ( ) -> __setLocation ( $ location ) ; } return $ this ; }
|
Allows to set the SoapClient location to call
|
53,918
|
public static function convertStringHeadersToArray ( $ headers ) { $ lines = explode ( "\r\n" , $ headers ) ; $ headers = [ ] ; foreach ( $ lines as $ line ) { if ( strpos ( $ line , ':' ) ) { $ headerParts = explode ( ':' , $ line ) ; $ headers [ $ headerParts [ 0 ] ] = trim ( implode ( ':' , array_slice ( $ headerParts , 1 ) ) ) ; } } return $ headers ; }
|
Returns an associative array between the headers name and their respective values
|
53,919
|
public function browse ( $ base = '0' , $ browseflag = 'BrowseDirectChildren' , $ start = 0 , $ count = 0 ) { libxml_use_internal_errors ( true ) ; $ args = array ( 'ObjectID' => $ base , 'BrowseFlag' => $ browseflag , 'Filter' => '' , 'StartingIndex' => $ start , 'RequestedCount' => $ count , 'SortCriteria' => '' , ) ; $ response = $ this -> upnp -> sendRequestToDevice ( 'Browse' , $ args , $ this -> ctrlurl , $ type = 'ContentDirectory' ) ; if ( $ response ) { $ doc = new \ DOMDocument ( ) ; $ doc -> loadXML ( $ response ) ; $ containers = $ doc -> getElementsByTagName ( 'container' ) ; $ items = $ doc -> getElementsByTagName ( 'item' ) ; $ directories = array ( ) ; foreach ( $ containers as $ container ) { foreach ( $ container -> attributes as $ attr ) { if ( $ attr -> name == 'id' ) { $ id = $ attr -> nodeValue ; } if ( $ attr -> name === 'parentID' ) { $ parentId = $ attr -> nodeValue ; } } $ directories [ $ id ] [ 'parentID' ] = $ parentId ; foreach ( $ container -> childNodes as $ property ) { foreach ( $ property -> attributes as $ attr ) { } $ directories [ $ id ] [ $ property -> nodeName ] = $ property -> nodeValue ; } } foreach ( $ items as $ item ) { foreach ( $ item -> attributes as $ attr ) { if ( $ attr -> name == 'id' ) { $ id = $ attr -> nodeValue ; } if ( $ attr -> name === 'parentID' ) { $ parentId = $ attr -> nodeValue ; } } $ directories [ $ id ] [ 'parentID' ] = $ parentId ; foreach ( $ item -> childNodes as $ property ) { if ( $ property -> nodeName === 'res' ) { $ att_length = $ property -> attributes -> length ; for ( $ i = 0 ; $ i < $ att_length ; ++ $ i ) { if ( $ property -> attributes -> item ( $ i ) -> name === 'protocolInfo' && strpos ( $ property -> attributes -> item ( $ i ) -> value , 'video' ) ) { $ directories [ $ id ] [ 'video' ] = $ property -> nodeValue ; } } } $ directories [ $ id ] [ $ property -> nodeName ] = $ property -> nodeValue ; } } return $ directories ; } return false ; }
|
BrowseDirectChildren or BrowseMetadata
|
53,920
|
public function connectUrl ( $ url ) { if ( ! preg_match ( '!^ftp(?<ssl>s?)://(?<user>[^:]+):(?<pass>[^@]+)@(?<host>[^:/]+)(?:[:](?<port>\d+))?(?<path>.*)$!i' , $ url , $ match ) ) { throw new FtpException ( 'Url must be in format: ftp[s]://username:password@hostname[:port]/[path]' ) ; } if ( empty ( $ match [ 'port' ] ) ) { $ match [ 'port' ] = '21' ; } $ connectMethod = ( bool ) $ match [ 'ssl' ] ? 'ssl_connect' : 'connect' ; $ this -> $ connectMethod ( $ match [ 'host' ] , $ match [ 'port' ] ) ; if ( ! $ this -> login ( $ match [ 'user' ] , $ match [ 'pass' ] ) ) { throw new FtpException ( "Login failed as " . $ match [ 'user' ] ) ; } $ match [ 'path' ] = trim ( $ match [ 'path' ] , '/' ) ; if ( ! empty ( $ match [ 'path' ] ) ) { $ this -> chdir ( "/$match[path]/" ) ; } }
|
Interpret connection info from url string
|
53,921
|
public function getChannels ( ) { $ response = $ this -> channel -> addMessage ( 'query/apps' , false ) ; $ xml = simplexml_load_string ( $ response ) ; $ channels = array ( ) ; foreach ( $ xml -> app as $ app ) { $ app_id = $ app -> attributes ( ) -> id ; $ channels [ ( string ) $ app_id ] = array ( 'name' => ( string ) $ app , 'launch_url' => $ this -> location . 'launch/' . ( string ) $ app_id , 'icon_url' => $ this -> location . 'query/icon/' . ( string ) $ app_id , ) ; } return $ channels ; }
|
to not confuse with communication channels consider renaming to getApplications
|
53,922
|
private function moveReaderToCurrent ( ) { if ( ( $ this -> reader -> nodeType === XMLReader :: NONE ) or ( $ this -> reader -> nodeType !== XMLReader :: ELEMENT ) or ( $ this -> localName && $ this -> localName !== $ this -> reader -> localName ) ) { self :: next ( ) ; } }
|
move cursor to the next element but only if it s not yet there
|
53,923
|
public function expand ( DOMNode $ basenode = null ) { if ( null === $ basenode ) { $ basenode = new DomDocument ( ) ; } if ( $ basenode instanceof DOMDocument ) { $ doc = $ basenode ; } else { $ doc = $ basenode -> ownerDocument ; } if ( false === $ node = $ this -> reader -> expand ( $ basenode ) ) { throw new BadMethodCallException ( 'Unable to expand node.' ) ; } if ( $ node -> ownerDocument !== $ doc ) { $ node = $ doc -> importNode ( $ node , true ) ; } return $ node ; }
|
XMLReader expand node and import it into a DOMNode with a DOMDocument
|
53,924
|
public static function dump ( XMLReader $ reader , $ return = FALSE ) { $ node = new self ( $ reader ) ; $ nodeType = $ reader -> nodeType ; $ nodeName = $ node -> getNodeTypeName ( ) ; $ extra = '' ; if ( $ reader -> nodeType === XMLReader :: ELEMENT ) { $ extra = '<' . $ reader -> name . '> ' ; $ extra .= sprintf ( "(isEmptyElement: %s) " , $ reader -> isEmptyElement ? 'Yes' : 'No' ) ; } if ( $ reader -> nodeType === XMLReader :: END_ELEMENT ) { $ extra = '</' . $ reader -> name . '> ' ; } if ( $ reader -> nodeType === XMLReader :: ATTRIBUTE ) { $ str = $ reader -> value ; $ len = strlen ( $ str ) ; if ( $ len > 20 ) { $ str = substr ( $ str , 0 , 17 ) . '...' ; } $ str = strtr ( $ str , array ( "\n" => '\n' ) ) ; $ extra = sprintf ( '%s = (%d) "%s" ' , $ reader -> name , strlen ( $ str ) , $ str ) ; } if ( $ reader -> nodeType === XMLReader :: TEXT || $ reader -> nodeType === XMLReader :: WHITESPACE || $ reader -> nodeType === XMLReader :: SIGNIFICANT_WHITESPACE ) { $ str = $ reader -> readString ( ) ; $ len = strlen ( $ str ) ; if ( $ len > 20 ) { $ str = substr ( $ str , 0 , 17 ) . '...' ; } $ str = strtr ( $ str , array ( "\n" => '\n' ) ) ; $ extra = sprintf ( '(%d) "%s" ' , strlen ( $ str ) , $ str ) ; } $ label = sprintf ( "(#%d) %s %s" , $ nodeType , $ nodeName , $ extra ) ; if ( $ return ) { return $ label ; } printf ( "%s%s\n" , str_repeat ( ' ' , $ reader -> depth ) , $ label ) ; return null ; }
|
debug utility method
|
53,925
|
public function shift ( $ bytes ) { $ bufferLen = strlen ( $ this -> buffer ) ; if ( $ bytes === $ bufferLen ) { $ return = $ this -> buffer ; $ this -> buffer = '' ; } else { $ return = substr ( $ this -> buffer , 0 , $ bytes ) ; $ this -> buffer = substr ( $ this -> buffer , $ bytes ) ; } return $ return ; }
|
shift bytes from buffer
|
53,926
|
public function getControlURL ( $ description_url , $ service = 'AVTransport' ) { $ description = $ this -> getDescription ( $ description_url ) ; switch ( $ service ) { case 'AVTransport' : $ serviceType = 'urn:schemas-upnp-org:service:AVTransport:1' ; break ; default : $ serviceType = 'urn:schemas-upnp-org:service:AVTransport:1' ; break ; } foreach ( $ description [ 'device' ] [ 'serviceList' ] [ 'service' ] as $ service ) { if ( $ service [ 'serviceType' ] == $ serviceType ) { $ url = parse_url ( $ description_url ) ; return $ url [ 'scheme' ] . '://' . $ url [ 'host' ] . ':' . $ url [ 'port' ] . $ service [ 'controlURL' ] ; } } }
|
this should be moved to the upnp and renderer model
|
53,927
|
public function mod ( $ dividend , $ divisor ) { if ( $ divisor === 0 ) { return 0 ; } $ modulus = $ dividend % $ divisor ; if ( $ modulus < 0 ) { $ modulus += $ divisor ; } return $ modulus ; }
|
The PHP modulus function returns a negative modulus for a negative dividend . This algorithm requires a traditional modulus function where the modulus is always positive .
|
53,928
|
public function createIndex ( ) : bool { $ class = $ this -> class ; $ indexParams = [ 'index' => $ this -> index , ] ; if ( count ( $ this -> notAnalyzedFields ) ) { $ indexParams [ 'body' ] = [ 'mappings' => [ $ class => [ '_source' => [ 'enabled' => true ] , 'properties' => $ this -> createNotAnalyzedFieldsMapping ( $ this -> notAnalyzedFields ) , ] ] ] ; } $ this -> client -> indices ( ) -> create ( $ indexParams ) ; $ response = $ this -> client -> cluster ( ) -> health ( [ 'index' => $ this -> index , 'wait_for_status' => 'yellow' , 'timeout' => '5s' , ] ) ; return isset ( $ response [ 'status' ] ) && $ response [ 'status' ] !== 'red' ; }
|
Creates the index for this repository s ReadModel .
|
53,929
|
public function deleteIndex ( ) : bool { $ indexParams = [ 'index' => $ this -> index , 'timeout' => '5s' , ] ; $ this -> client -> indices ( ) -> delete ( $ indexParams ) ; $ response = $ this -> client -> cluster ( ) -> health ( [ 'index' => $ this -> index , 'wait_for_status' => 'yellow' , 'timeout' => '5s' , ] ) ; return isset ( $ response [ 'status' ] ) && $ response [ 'status' ] !== 'red' ; }
|
Deletes the index for this repository s ReadModel .
|
53,930
|
public static function calDaysInMonth ( $ calendar_id , $ month , $ year ) { switch ( $ calendar_id ) { case CAL_FRENCH : return self :: calDaysInMonthFrench ( $ year , $ month ) ; case CAL_GREGORIAN : return self :: calDaysInMonthCalendar ( self :: $ gregorian_calendar , $ year , $ month ) ; case CAL_JEWISH : return self :: calDaysInMonthCalendar ( self :: $ jewish_calendar , $ year , $ month ) ; case CAL_JULIAN : return self :: calDaysInMonthCalendar ( self :: $ julian_calendar , $ year , $ month ) ; default : return trigger_error ( 'invalid calendar ID ' . $ calendar_id , E_USER_WARNING ) ; } }
|
Return the number of days in a month for a given year and calendar .
|
53,931
|
private static function calDaysInMonthFrench ( $ year , $ month ) { if ( $ month == 13 && $ year == 14 && self :: shouldEmulateBug67976 ( ) ) { return - 2380948 ; } elseif ( $ year > 14 ) { $ error_msg = PHP_VERSION_ID < 70200 ? 'invalid date.' : 'invalid date' ; return trigger_error ( $ error_msg , E_USER_WARNING ) ; } else { return self :: calDaysInMonthCalendar ( self :: $ french_calendar , $ year , $ month ) ; } }
|
Calculate the number of days in a month in the French calendar .
|
53,932
|
public static function calFromJd ( $ julian_day , $ calendar_id ) { switch ( $ calendar_id ) { case CAL_FRENCH : return self :: calFromJdCalendar ( $ julian_day , self :: jdToFrench ( $ julian_day ) , self :: $ MONTH_NAMES_FRENCH , self :: $ MONTH_NAMES_FRENCH ) ; case CAL_GREGORIAN : return self :: calFromJdCalendar ( $ julian_day , self :: jdToGregorian ( $ julian_day ) , self :: $ MONTH_NAMES , self :: $ MONTH_NAMES_SHORT ) ; case CAL_JEWISH : $ months = self :: jdMonthNameJewishMonths ( $ julian_day ) ; $ cal = self :: calFromJdCalendar ( $ julian_day , self :: jdToCalendar ( self :: $ jewish_calendar , $ julian_day , 347998 , 324542846 ) , $ months , $ months ) ; if ( ( $ julian_day < 347998 || $ julian_day > 324542846 ) && ! self :: shouldEmulateBug67976 ( ) ) { $ cal [ 'dow' ] = null ; $ cal [ 'dayname' ] = '' ; $ cal [ 'abbrevdayname' ] = '' ; } return $ cal ; case CAL_JULIAN : return self :: calFromJdCalendar ( $ julian_day , self :: jdToJulian ( $ julian_day ) , self :: $ MONTH_NAMES , self :: $ MONTH_NAMES_SHORT ) ; default : return trigger_error ( 'invalid calendar ID ' . $ calendar_id , E_USER_WARNING ) ; } }
|
Converts from Julian Day Count to a supported calendar .
|
53,933
|
private static function calFromJdCalendar ( $ julian_day , $ mdy , $ months , $ months_short ) { list ( $ month , $ day , $ year ) = explode ( '/' , $ mdy ) ; return array ( 'date' => $ month . '/' . $ day . '/' . $ year , 'month' => ( int ) $ month , 'day' => ( int ) $ day , 'year' => ( int ) $ year , 'dow' => self :: jdDayOfWeek ( $ julian_day , 0 ) , 'abbrevdayname' => self :: jdDayOfWeek ( $ julian_day , 2 ) , 'dayname' => self :: jdDayOfWeek ( $ julian_day , 1 ) , 'abbrevmonth' => $ months_short [ $ month ] , 'monthname' => $ months [ $ month ] , ) ; }
|
Convert a Julian day number to a calendar and provide details .
|
53,934
|
public static function calInfo ( $ calendar_id ) { switch ( $ calendar_id ) { case CAL_FRENCH : return self :: calInfoCalendar ( self :: $ MONTH_NAMES_FRENCH , self :: $ MONTH_NAMES_FRENCH , 30 , 'French' , 'CAL_FRENCH' ) ; case CAL_GREGORIAN : return self :: calInfoCalendar ( self :: $ MONTH_NAMES , self :: $ MONTH_NAMES_SHORT , 31 , 'Gregorian' , 'CAL_GREGORIAN' ) ; case CAL_JEWISH : $ months = self :: shouldEmulateBug54254 ( ) ? self :: $ MONTH_NAMES_JEWISH_54254 : self :: $ MONTH_NAMES_JEWISH_LEAP_YEAR ; return self :: calInfoCalendar ( $ months , $ months , 30 , 'Jewish' , 'CAL_JEWISH' ) ; case CAL_JULIAN : return self :: calInfoCalendar ( self :: $ MONTH_NAMES , self :: $ MONTH_NAMES_SHORT , 31 , 'Julian' , 'CAL_JULIAN' ) ; case - 1 : return array ( CAL_GREGORIAN => self :: calInfo ( CAL_GREGORIAN ) , CAL_JULIAN => self :: calInfo ( CAL_JULIAN ) , CAL_JEWISH => self :: calInfo ( CAL_JEWISH ) , CAL_FRENCH => self :: calInfo ( CAL_FRENCH ) , ) ; default : return trigger_error ( 'invalid calendar ID ' . $ calendar_id , E_USER_WARNING ) ; } }
|
Returns information about a particular calendar .
|
53,935
|
private static function calInfoCalendar ( $ month_names , $ month_names_short , $ max_days_in_month , $ calendar_name , $ calendar_symbol ) { return array ( 'months' => array_slice ( $ month_names , 1 , null , true ) , 'abbrevmonths' => array_slice ( $ month_names_short , 1 , null , true ) , 'maxdaysinmonth' => $ max_days_in_month , 'calname' => $ calendar_name , 'calsymbol' => $ calendar_symbol , ) ; }
|
Returns information about the French calendar .
|
53,936
|
public static function calToJd ( $ calendar_id , $ month , $ day , $ year ) { switch ( $ calendar_id ) { case CAL_FRENCH : return self :: frenchToJd ( $ month , $ day , $ year ) ; case CAL_GREGORIAN : return self :: gregorianToJd ( $ month , $ day , $ year ) ; case CAL_JEWISH : return self :: jewishToJd ( $ month , $ day , $ year ) ; case CAL_JULIAN : return self :: julianToJd ( $ month , $ day , $ year ) ; default : return trigger_error ( 'invalid calendar ID ' . $ calendar_id . '.' , E_USER_WARNING ) ; } }
|
Converts from a supported calendar to Julian Day Count
|
53,937
|
public static function easterDate ( $ year ) { if ( $ year < 1970 || $ year > 2037 ) { return trigger_error ( 'This function is only valid for years between 1970 and 2037 inclusive' , E_USER_WARNING ) ; } $ days = self :: $ gregorian_calendar -> easterDays ( $ year ) ; $ date_time = new \ DateTime ( 'now' , new \ DateTimeZone ( date_default_timezone_get ( ) ) ) ; $ offset_seconds = ( int ) $ date_time -> format ( 'Z' ) ; if ( $ days < 11 ) { return self :: jdtounix ( self :: $ gregorian_calendar -> ymdToJd ( $ year , 3 , $ days + 21 ) ) - $ offset_seconds ; } else { return self :: jdtounix ( self :: $ gregorian_calendar -> ymdToJd ( $ year , 4 , $ days - 10 ) ) - $ offset_seconds ; } }
|
Get Unix timestamp for midnight on Easter of a given year .
|
53,938
|
public static function easterDays ( $ year , $ method ) { if ( $ method == CAL_EASTER_ALWAYS_JULIAN || $ method == CAL_EASTER_ROMAN && $ year <= 1582 || $ year <= 1752 && $ method != CAL_EASTER_ROMAN && $ method != CAL_EASTER_ALWAYS_GREGORIAN ) { return self :: $ julian_calendar -> easterDays ( $ year ) ; } else { return self :: $ gregorian_calendar -> easterDays ( $ year ) ; } }
|
Get number of days after March 21 on which Easter falls for a given year .
|
53,939
|
public static function frenchToJd ( $ month , $ day , $ year ) { if ( $ year <= 0 ) { return 0 ; } else { return self :: $ french_calendar -> ymdToJd ( $ year , $ month , $ day ) ; } }
|
Converts a date from the French Republican Calendar to a Julian Day Count .
|
53,940
|
public static function gregorianToJd ( $ month , $ day , $ year ) { if ( $ year == 0 ) { return 0 ; } else { return self :: $ gregorian_calendar -> ymdToJd ( $ year , $ month , $ day ) ; } }
|
Converts a Gregorian date to Julian Day Count .
|
53,941
|
public static function jdDayOfWeek ( $ julian_day , $ mode ) { $ day_of_week = ( $ julian_day + 1 ) % 7 ; if ( $ day_of_week < 0 ) { $ day_of_week += 7 ; } switch ( $ mode ) { case 1 : return self :: $ DAY_NAMES [ $ day_of_week ] ; case 2 : return self :: $ DAY_NAMES_SHORT [ $ day_of_week ] ; default : return $ day_of_week ; } }
|
Returns the day of the week .
|
53,942
|
public static function jdMonthName ( $ julian_day , $ mode ) { switch ( $ mode ) { case CAL_MONTH_GREGORIAN_LONG : return self :: jdMonthNameCalendar ( self :: $ gregorian_calendar , $ julian_day , self :: $ MONTH_NAMES ) ; case CAL_MONTH_JULIAN_LONG : return self :: jdMonthNameCalendar ( self :: $ julian_calendar , $ julian_day , self :: $ MONTH_NAMES ) ; case CAL_MONTH_JULIAN_SHORT : return self :: jdMonthNameCalendar ( self :: $ julian_calendar , $ julian_day , self :: $ MONTH_NAMES_SHORT ) ; case CAL_MONTH_JEWISH : return self :: jdMonthNameCalendar ( self :: $ jewish_calendar , $ julian_day , self :: jdMonthNameJewishMonths ( $ julian_day ) ) ; case CAL_MONTH_FRENCH : return self :: jdMonthNameCalendar ( self :: $ french_calendar , $ julian_day , self :: $ MONTH_NAMES_FRENCH ) ; case CAL_MONTH_GREGORIAN_SHORT : default : return self :: jdMonthNameCalendar ( self :: $ gregorian_calendar , $ julian_day , self :: $ MONTH_NAMES_SHORT ) ; } }
|
Returns a month name .
|
53,943
|
private static function jdMonthNameCalendar ( CalendarInterface $ calendar , $ julian_day , $ months ) { list ( , $ month ) = $ calendar -> jdToYmd ( $ julian_day ) ; return $ months [ $ month ] ; }
|
Calculate the month - name for a given julian day in a given calendar with given set of month names .
|
53,944
|
private static function jdMonthNameJewishMonths ( $ julian_day ) { list ( , , $ year ) = explode ( '/' , self :: jdToCalendar ( self :: $ jewish_calendar , $ julian_day , 347998 , 324542846 ) ) ; if ( self :: $ jewish_calendar -> isLeapYear ( $ year ) ) { return self :: shouldEmulateBug54254 ( ) ? self :: $ MONTH_NAMES_JEWISH_54254 : self :: $ MONTH_NAMES_JEWISH_LEAP_YEAR ; } else { return self :: shouldEmulateBug54254 ( ) ? self :: $ MONTH_NAMES_JEWISH_54254 : self :: $ MONTH_NAMES_JEWISH ; } }
|
Determine which month names to use for the Jewish calendar .
|
53,945
|
public static function jdToGregorian ( $ julian_day ) { $ MAX_JD = PHP_INT_SIZE == 4 ? 536838866 : 2305843009213661906 ; return self :: jdToCalendar ( self :: $ gregorian_calendar , $ julian_day , 1 , $ MAX_JD ) ; }
|
Converts Julian Day Count to Gregorian date .
|
53,946
|
public static function jdToJewish ( $ julian_day , $ hebrew , $ fl ) { if ( $ hebrew ) { if ( $ julian_day < 347998 || $ julian_day > 4000075 ) { $ error_msg = PHP_VERSION_ID < 70200 ? 'Year out of range (0-9999).' : 'Year out of range (0-9999)' ; return trigger_error ( $ error_msg , E_USER_WARNING ) ; } return self :: $ jewish_calendar -> jdToHebrew ( $ julian_day , ( bool ) ( $ fl & CAL_JEWISH_ADD_ALAFIM_GERESH ) , ( bool ) ( $ fl & CAL_JEWISH_ADD_ALAFIM ) , ( bool ) ( $ fl & CAL_JEWISH_ADD_GERESHAYIM ) ) ; } else { return self :: jdToCalendar ( self :: $ jewish_calendar , $ julian_day , 347998 , 324542846 ) ; } }
|
Converts a Julian day count to a Jewish calendar date .
|
53,947
|
public static function jdToJulian ( $ julian_day ) { $ MAX_JD = PHP_INT_SIZE == 4 ? 536838829 : 784368370349 ; return self :: jdToCalendar ( self :: $ julian_calendar , $ julian_day , 1 , $ MAX_JD ) ; }
|
Converts a Julian Day Count to a Julian Calendar Date .
|
53,948
|
public static function jewishToJd ( $ month , $ day , $ year ) { if ( $ year <= 0 ) { return 0 ; } else { return self :: $ jewish_calendar -> ymdToJd ( $ year , $ month , $ day ) ; } }
|
Converts a date in the Jewish Calendar to Julian Day Count .
|
53,949
|
public static function julianToJd ( $ month , $ day , $ year ) { if ( $ year == 0 ) { return 0 ; } else { return self :: $ julian_calendar -> ymdToJd ( $ year , $ month , $ day ) ; } }
|
Converts a Julian Calendar date to Julian Day Count .
|
53,950
|
public static function unixToJd ( $ timestamp ) { if ( $ timestamp < 0 ) { return false ; } else { return self :: GregorianToJd ( gmdate ( 'n' , $ timestamp ) , gmdate ( 'j' , $ timestamp ) , gmdate ( 'Y' , $ timestamp ) ) ; } }
|
Convert Unix timestamp to Julian Day .
|
53,951
|
protected function jdToY ( $ julian_day ) { $ year = max ( ( int ) ( ( ( $ julian_day - 347998 ) * 98496 ) / 35975351 ) - 1 , 1 ) ; while ( $ julian_day >= $ this -> yToJd ( $ year + 1 ) ) { $ year ++ ; } return $ year ; }
|
Convert a Julian day number into a year .
|
53,952
|
protected function yToJd ( $ year ) { $ div19 = ( int ) ( ( $ year - 1 ) / 19 ) ; $ mod19 = ( $ year - 1 ) % 19 ; $ months = 235 * $ div19 + 12 * $ mod19 + ( int ) ( ( 7 * $ mod19 + 1 ) / 19 ) ; $ parts = 204 + 793 * ( $ months % 1080 ) ; $ hours = 5 + 12 * $ months + 793 * ( int ) ( $ months / 1080 ) + ( int ) ( $ parts / 1080 ) ; $ conjunction = 1080 * ( $ hours % 24 ) + ( $ parts % 1080 ) ; $ julian_day = 1 + 29 * $ months + ( int ) ( $ hours / 24 ) ; if ( $ conjunction >= 19440 || $ julian_day % 7 === 2 && $ conjunction >= 9924 && ! $ this -> isLeapYear ( $ year ) || $ julian_day % 7 === 1 && $ conjunction >= 16789 && $ this -> isLeapYear ( $ year - 1 ) ) { $ julian_day ++ ; } return $ julian_day + self :: $ ROSH_HASHANAH [ $ julian_day % 7 ] ; }
|
Calculate the Julian Day number of the first day in a year .
|
53,953
|
private function yearType ( $ year ) { $ year_length = $ this -> yToJd ( $ year + 1 ) - $ this -> yToJd ( $ year ) ; if ( $ year_length === 353 || $ year_length === 383 ) { return self :: DEFECTIVE_YEAR ; } elseif ( $ year_length === 355 || $ year_length === 385 ) { return self :: COMPLETE_YEAR ; } else { return self :: REGULAR_YEAR ; } }
|
Determine whether a year is normal defective or complete .
|
53,954
|
protected function hebrewMonthNames ( $ year ) { $ leap_year = $ this -> isLeapYear ( $ year ) ; return array ( 1 => "\xfa\xf9\xf8\xe9" , "\xe7\xf9\xe5\xef" , "\xeb\xf1\xec\xe5" , "\xe8\xe1\xfa" , "\xf9\xe1\xe8" , $ leap_year ? ( $ this -> options [ self :: EMULATE_BUG_54254 ] ? "\xe0\xe3\xf8" : "\xe0\xe3\xf8 \xe0'" ) : "\xe0\xe3\xf8" , $ leap_year ? ( $ this -> options [ self :: EMULATE_BUG_54254 ] ? "'\xe0\xe3\xf8 \xe1" : "\xe0\xe3\xf8 \xe1'" ) : "\xe0\xe3\xf8" , "\xf0\xe9\xf1\xef" , "\xe0\xe9\xe9\xf8" , "\xf1\xe9\xe5\xef" , "\xfa\xee\xe5\xe6" , "\xe0\xe1" , "\xe0\xec\xe5\xec" , ) ; }
|
Hebrew month names .
|
53,955
|
private function numberToNumerals ( $ number , array $ numerals ) { $ string = '' ; while ( $ number > 0 ) { foreach ( $ numerals as $ n => $ t ) { if ( $ number >= $ n ) { $ string .= $ t ; $ number -= $ n ; break ; } } } return $ string ; }
|
Convert a number into a string in the style of roman numerals
|
53,956
|
public function numberToHebrewNumerals ( $ number , $ show_thousands ) { if ( $ show_thousands || $ number % 1000 === 0 ) { $ thousands = ( int ) ( $ number / 1000 ) ; } else { $ thousands = 0 ; } $ number = $ number % 1000 ; $ hebrew = $ this -> numberToNumerals ( $ number , self :: $ HEBREW_NUMERALS_UTF8 ) ; if ( strlen ( $ hebrew ) === 2 ) { $ hebrew .= self :: GERESH ; } elseif ( strlen ( $ hebrew ) > 2 ) { $ hebrew = substr ( $ hebrew , 0 , - 2 ) . strtr ( substr ( $ hebrew , - 2 ) , self :: $ FINAL_FORMS_UTF8 ) ; $ hebrew = substr_replace ( $ hebrew , self :: GERSHAYIM , - 2 , 0 ) ; } if ( $ thousands ) { if ( $ hebrew ) { $ hebrew = $ this -> numberToHebrewNumerals ( $ thousands , $ show_thousands ) . $ hebrew ; } else { $ hebrew = $ this -> numberToHebrewNumerals ( $ thousands , $ show_thousands ) . ' ' . self :: ALAFIM ; } } return $ hebrew ; }
|
Convert a number into Hebrew numerals using UTF8 .
|
53,957
|
protected function numberToHebrewNumeralsIso8859 ( $ number , $ gereshayim ) { $ hebrew = $ this -> numberToNumerals ( $ number , self :: $ HEBREW_NUMERALS_ISO8859_8 ) ; if ( $ gereshayim ) { return $ this -> addGereshayim ( $ hebrew ) ; } else { return $ hebrew ; } }
|
Convert a number into Hebrew numerals using ISO8859 - 8 .
|
53,958
|
protected function yearToHebrewNumerals ( $ year , $ alafim_geresh , $ alafim , $ gereshayim ) { if ( $ year < 1000 ) { return $ this -> numberToHebrewNumeralsIso8859 ( $ year , $ gereshayim ) ; } else { $ thousands = $ this -> numberToHebrewNumeralsIso8859 ( ( int ) ( $ year / 1000 ) , false ) ; if ( $ alafim_geresh ) { $ thousands .= self :: GERESH_ISO8859 ; } if ( $ alafim ) { $ thousands .= ' ' . self :: ALAFIM_ISO8859 . ' ' ; } return $ thousands . $ this -> numberToHebrewNumeralsIso8859 ( $ year % 1000 , $ gereshayim ) ; } }
|
Format a year using Hebrew numerals .
|
53,959
|
public function jdToHebrew ( $ julian_day , $ alafim_garesh , $ alafim , $ gereshayim ) { list ( $ year , $ month , $ day ) = $ this -> jdToYmd ( $ julian_day ) ; return $ this -> numberToHebrewNumeralsIso8859 ( $ day , $ gereshayim ) . ' ' . $ this -> hebrewMonthName ( $ year , $ month ) . ' ' . $ this -> yearToHebrewNumerals ( $ year , $ alafim_garesh , $ alafim , $ gereshayim ) ; }
|
Convert a Julian Day number into a Hebrew date .
|
53,960
|
public function getVideoByUrl ( string $ videoUrl ) : Video { $ url = new Nette \ Http \ Url ( $ videoUrl ) ; if ( stripos ( $ url -> host , 'youtu.be' ) !== false ) { return $ this -> getVideo ( trim ( $ url -> getPath ( ) , '/' ) ) ; } $ videoId = $ url -> getQueryParameter ( 'v' ) ; if ( stripos ( $ url -> host , 'youtube.com' ) === false || $ videoId === null ) { throw new Nette \ InvalidArgumentException ( 'videoUrl must be valid youtube url.' ) ; } return $ this -> getVideo ( $ videoId ) ; }
|
Fetches video data by youtube url
|
53,961
|
public function getVideo ( string $ videoId ) : Video { return $ this -> parseData ( $ this -> getData ( $ videoId ) , $ videoId ) ; }
|
Fetches video data
|
53,962
|
function isGood ( ) { $ meta = stream_get_meta_data ( $ this -> stream ) ; $ mode = $ meta [ 'mode' ] ; return false === strpos ( $ mode , 'r' ) || true === strpos ( $ mode , 'r+' ) ; }
|
Checks if sink stream is good for write .
|
53,963
|
public function privateKeyToDer ( $ privateKey , $ privateKyePassword = '' ) { try { if ( strlen ( $ privateKyePassword ) === 0 ) { return CryptoVirgilKeyPair :: privateKeyToDER ( $ privateKey ) ; } return CryptoVirgilKeyPair :: privateKeyToDER ( $ this -> encryptPrivateKey ( $ privateKey , $ privateKyePassword ) , $ privateKyePassword ) ; } catch ( Exception $ exception ) { throw new PrivateKeyToDerConvertingException ( $ exception -> getMessage ( ) , $ exception -> getCode ( ) ) ; } }
|
Converts private key to DER format .
|
53,964
|
public function publicKeyToDer ( $ publicKey ) { try { return CryptoVirgilKeyPair :: publicKeyToDER ( $ publicKey ) ; } catch ( Exception $ exception ) { throw new PublicKeyToDerConvertingException ( $ exception -> getMessage ( ) , $ exception -> getCode ( ) ) ; } }
|
Converts public key to DER format .
|
53,965
|
public function isKeyPair ( $ publicKey , $ privateKey ) { try { return CryptoVirgilKeyPair :: isKeyPairMatch ( $ publicKey , $ privateKey ) ; } catch ( Exception $ exception ) { throw new InvalidKeyPairException ( $ exception -> getMessage ( ) , $ exception -> getCode ( ) ) ; } }
|
Checks if given keys are parts of the same key pair .
|
53,966
|
public function computeHash ( $ publicKeyDER , $ hashAlgorithm ) { try { return ( new CryptoVirgilHash ( $ hashAlgorithm ) ) -> hash ( $ publicKeyDER ) ; } catch ( Exception $ exception ) { throw new PublicKeyHashComputationException ( $ exception -> getMessage ( ) , $ exception -> getCode ( ) ) ; } }
|
Calculates key hash by the hash algorithm .
|
53,967
|
public function extractPublicKey ( $ privateKey , $ privateKeyPassword ) { try { return CryptoVirgilKeyPair :: extractPublicKey ( $ privateKey , $ privateKeyPassword ) ; } catch ( Exception $ exception ) { throw new PublicKeyExtractionException ( $ exception -> getMessage ( ) , $ exception -> getCode ( ) ) ; } }
|
Extracts public key from a private key .
|
53,968
|
public function encryptPrivateKey ( $ privateKey , $ password ) { try { return CryptoVirgilKeyPair :: encryptPrivateKey ( $ privateKey , $ password ) ; } catch ( Exception $ exception ) { throw new PrivateKeyEncryptionException ( $ exception -> getMessage ( ) , $ exception -> getCode ( ) ) ; } }
|
Encrypts private key with a password .
|
53,969
|
public function decryptPrivateKey ( $ privateKey , $ privateKeyPassword ) { try { return CryptoVirgilKeyPair :: decryptPrivateKey ( $ privateKey , $ privateKeyPassword ) ; } catch ( Exception $ exception ) { throw new PrivateKeyDecryptionException ( $ exception -> getMessage ( ) , $ exception -> getCode ( ) ) ; } }
|
Decrypts private key with a password .
|
53,970
|
public function sign ( $ content , $ privateKey ) { try { return ( new CryptoVirgilSigner ( $ this -> hashAlgorithm ) ) -> sign ( $ content , $ privateKey ) ; } catch ( Exception $ exception ) { throw new ContentSigningException ( $ exception -> getMessage ( ) , $ exception -> getCode ( ) ) ; } }
|
Sign content with a private key .
|
53,971
|
public function verify ( $ content , $ signature , $ publicKey ) { try { return ( new CryptoVirgilSigner ( $ this -> hashAlgorithm ) ) -> verify ( $ content , $ signature , $ publicKey ) ; } catch ( Exception $ exception ) { throw new ContentVerificationException ( $ exception -> getMessage ( ) , $ exception -> getCode ( ) ) ; } }
|
Verify content with a public key and signature .
|
53,972
|
public function signStream ( $ stream , $ privateKey ) { try { $ virgilSourceStream = new VirgilStreamDataSource ( $ stream ) ; $ virgilSourceStream -> reset ( ) ; return ( new CryptoVirgilStreamSigner ( $ this -> hashAlgorithm ) ) -> sign ( $ virgilSourceStream , $ privateKey ) ; } catch ( Exception $ exception ) { throw new ContentSigningException ( $ exception -> getMessage ( ) , $ exception -> getCode ( ) ) ; } }
|
Sign stream with a private key
|
53,973
|
public function verifyStream ( $ stream , $ signature , $ publicKey ) { try { $ virgilSourceStream = new VirgilStreamDataSource ( $ stream ) ; return ( new CryptoVirgilStreamSigner ( $ this -> hashAlgorithm ) ) -> verify ( $ virgilSourceStream , $ signature , $ publicKey ) ; } catch ( Exception $ exception ) { throw new ContentVerificationException ( $ exception -> getMessage ( ) , $ exception -> getCode ( ) ) ; } }
|
Verify stream with a public key and signature .
|
53,974
|
public function getOption ( $ option , $ default = null , $ namespace = 'options' ) { $ options = $ this -> getOptions ( $ namespace ) ; $ optionArr = explode ( '.' , $ option ) ; $ option = $ this -> getOptionFromArray ( $ options , $ optionArr , $ default , $ option ) ; return $ option ; }
|
Returns module option value . Dot character is used to separate sub arrays .
|
53,975
|
public static function fromString ( string $ input ) : self { $ input = preg_replace ( '/[^\d]/' , '' , $ input ) ; if ( ! is_numeric ( $ input ) ) { throw new \ InvalidArgumentException ( "Expects \$input to be a number, \"{$input}\" given." ) ; } $ checkDigit = ( int ) $ input [ strlen ( $ input ) - 1 ] ; $ number = substr ( $ input , 0 , strlen ( $ input ) - 1 ) ; return new self ( $ number , $ checkDigit ) ; }
|
Create a new number from an input that contains the check digit already .
|
53,976
|
public function moreFiles ( ) { $ oConfig = $ this -> getConfig ( ) ; $ iStart = $ oConfig -> getRequestParameter ( 'start' ) ? $ oConfig -> getRequestParameter ( 'start' ) : 0 ; $ iShopId = $ oConfig -> getConfigParam ( 'blMediaLibraryMultiShopCapability' ) ? $ oConfig -> getActiveShop ( ) -> getShopId ( ) : null ; $ aFiles = $ this -> _getFiles ( $ iStart , $ iShopId ) ; $ blLoadMore = ( $ iStart + 18 < $ this -> _getFileCount ( $ iShopId ) ) ; header ( 'Content-Type: application/json' ) ; die ( json_encode ( array ( 'files' => $ aFiles , 'more' => $ blLoadMore ) ) ) ; }
|
Load more files
|
53,977
|
private static function setupModule ( ) { if ( ! self :: tableExists ( 'ddmedia' ) ) { self :: executeSQL ( self :: $ _sCreateDdMediaSql ) ; } foreach ( self :: $ _aSetupDdMediaSQLs as $ sField => $ sSql ) { if ( ! self :: fieldExists ( $ sField , 'ddmedia' ) ) { self :: executeSQL ( $ sSql ) ; } } $ oConfig = Registry :: getConfig ( ) ; $ oConfig -> saveShopConfVar ( 'bool' , 'blModuleWasEnabled' , 'true' , $ oConfig -> getShopId ( ) , 'module:ddoewysiwyg' ) ; }
|
Execute the sql at the first time of the module installation .
|
53,978
|
private static function updateModule ( ) { $ oConfig = Registry :: getConfig ( ) ; $ oModule = oxNew ( Module :: class ) ; $ oModule -> load ( 'ddoewysiwyg' ) ; $ sCurrentVersion = $ oModule -> getInfo ( 'version' ) ; $ sInstalledVersion = $ oConfig -> getShopConfVar ( 'iInstallledVersion' , $ oConfig -> getShopId ( ) , 'module:ddoewysiwyg' ) ; if ( ! $ sInstalledVersion || version_compare ( $ sInstalledVersion , $ sCurrentVersion , '<' ) ) { if ( self :: $ __aUpdateSQLs ) { foreach ( self :: $ __aUpdateSQLs as $ sUpdateVersion => $ aSQLs ) { if ( ! $ sInstalledVersion || version_compare ( $ sUpdateVersion , $ sInstalledVersion , '>' ) ) { self :: executeSQLs ( $ aSQLs ) ; } } } $ oConfig -> saveShopConfVar ( 'str' , 'iInstallledVersion' , $ sCurrentVersion , $ oConfig -> getShopId ( ) , 'module:ddoewysiwyg' ) ; } }
|
Updates module if it was already installed .
|
53,979
|
private static function executeSQLs ( $ aSQLs ) { if ( count ( $ aSQLs ) > 0 ) { foreach ( $ aSQLs as $ sSQL ) { self :: executeSQL ( $ sSQL ) ; } } }
|
Executes given sql statements .
|
53,980
|
public function countKeys ( ComponentInterface $ subject , $ context = "GLOBAL" ) { $ options = array ( 'context' => $ context , 'type' => 'notification' , ) ; return $ this -> timelineManager -> countKeys ( $ subject , $ options ) ; }
|
count how many timeline had not be read
|
53,981
|
public function parse ( $ contents , $ includeDefaults = false ) { $ old_libxml_error = libxml_use_internal_errors ( true ) ; $ dom = new DOMDocument ; if ( @ $ dom -> loadHTML ( $ contents ) === false ) { throw new RuntimeException ( "Contents is empty" ) ; } libxml_use_internal_errors ( $ old_libxml_error ) ; foreach ( $ dom -> getElementsByTagName ( 'meta' ) as $ tag ) { if ( $ includeDefaults && $ tag -> hasAttribute ( 'name' ) && $ tag -> hasAttribute ( 'content' ) && $ tag -> getAttribute ( 'name' ) == 'description' ) { $ this -> addMeta ( 'non-og-description' , $ tag -> getAttribute ( 'content' ) , self :: APPEND ) ; } else if ( $ tag -> hasAttribute ( 'property' ) && $ tag -> hasAttribute ( 'content' ) ) { $ this -> addMeta ( $ tag -> getAttribute ( 'property' ) , $ tag -> getAttribute ( 'content' ) , self :: APPEND ) ; } } if ( $ includeDefaults ) { $ titles = $ dom -> getElementsByTagName ( 'title' ) ; if ( $ titles -> length > 0 ) { $ this -> addMeta ( 'non-og-title' , $ titles -> item ( 0 ) -> textContent , self :: APPEND ) ; } } unset ( $ dom ) ; return $ this ; }
|
parse html tags
|
53,982
|
private function loadBlocks ( DashboardInterface $ dashboard ) : void { $ blocks = $ this -> blockInteractor -> loadDashboardBlocks ( $ dashboard ) ; foreach ( $ blocks as $ block ) { $ this -> blocks [ $ block -> getId ( ) ] = $ block ; } }
|
load all the related nested blocks linked to one dashboard .
|
53,983
|
protected function _fromDualIfy ( $ queryString ) { $ statement = strtolower ( trim ( $ queryString ) ) ; if ( strpos ( $ statement , 'select' ) !== 0 || preg_match ( '/ from /' , $ statement ) ) { return $ queryString ; } return "{$queryString} FROM DUAL" ; }
|
Add FROM DUAL to SQL statements that are SELECT statements with no FROM clause specified
|
53,984
|
protected function _foreignKeySQL ( $ enableDisable ) { $ startQuote = $ this -> _startQuote ; $ endQuote = $ this -> _endQuote ; if ( ! empty ( $ this -> _config [ 'schema' ] ) ) { $ schemaName = strtoupper ( $ this -> _config [ 'schema' ] ) ; $ fromWhere = "from sys.all_constraints where owner = '{$schemaName}' and constraint_type = 'R'" ; } else { $ fromWhere = "from sys.user_constraints where constraint_type = 'R'" ; } return "declare cursor c is select owner, table_name, constraint_name {$fromWhere}; begin for r in c loop execute immediate 'alter table " . "{$startQuote}' || r.owner || '{$endQuote}." . "{$startQuote}' || r.table_name || '{$endQuote} " . "{$enableDisable} constraint " . "{$startQuote}' || r.constraint_name || '{$endQuote}'; end loop; end;" ; }
|
Get the SQL for enabling or disabling foreign keys
|
53,985
|
protected function registerRuntimeConfiguration ( ) { $ propel_conf = $ this -> app -> config [ 'propel.propel' ] ; if ( ! isset ( $ propel_conf [ 'runtime' ] [ 'connections' ] ) ) { throw new \ InvalidArgumentException ( 'Unable to guess Propel runtime config file. Please, initialize the "propel.runtime" parameter.' ) ; } $ serviceContainer = Propel :: getServiceContainer ( ) ; $ serviceContainer -> closeConnections ( ) ; $ serviceContainer -> checkVersion ( '2.0.0-dev' ) ; $ runtime_conf = $ propel_conf [ 'runtime' ] ; foreach ( $ runtime_conf [ 'connections' ] as $ connection_name ) { $ config = $ propel_conf [ 'database' ] [ 'connections' ] [ $ connection_name ] ; $ serviceContainer -> setAdapterClass ( $ connection_name , $ config [ 'adapter' ] ) ; $ manager = new ConnectionManagerSingle ( ) ; $ manager -> setConfiguration ( $ config + [ $ propel_conf [ 'paths' ] ] ) ; $ manager -> setName ( $ connection_name ) ; $ serviceContainer -> setConnectionManager ( $ connection_name , $ manager ) ; } $ serviceContainer -> setDefaultDatasource ( $ runtime_conf [ 'defaultConnection' ] ) ; $ has_default_logger = false ; if ( isset ( $ runtime_conf [ 'log' ] ) ) { $ has_default_logger = array_key_exists ( 'defaultLogger' , $ runtime_conf [ 'log' ] ) ; foreach ( $ runtime_conf [ 'log' ] as $ logger_name => $ logger_conf ) { $ serviceContainer -> setLoggerConfiguration ( $ logger_name , $ logger_conf ) ; } } if ( ! $ has_default_logger ) { $ serviceContainer -> setLogger ( 'defaultLogger' , app ( ) -> log -> getLogger ( ) ) ; } Propel :: setServiceContainer ( $ serviceContainer ) ; }
|
Register propel runtime configuration .
|
53,986
|
protected function hydrateComponents ( $ collection ) { $ componentsLocated = array ( ) ; foreach ( $ this -> components as $ model => $ components ) { foreach ( $ this -> locators as $ locator ) { if ( $ locator -> supports ( $ model ) ) { $ locator -> locate ( $ model , $ components ) ; foreach ( $ components as $ key => $ component ) { $ componentsLocated [ $ key ] = $ component ; } break ; } } } foreach ( $ collection as $ key => $ action ) { if ( $ action instanceof TimelineInterface ) { $ action = $ action -> getAction ( ) ; } foreach ( $ action -> getActionComponents ( ) as $ actionComponent ) { $ component = $ actionComponent -> getComponent ( ) ; if ( ! $ actionComponent -> isText ( ) && is_object ( $ component ) && null === $ component -> getData ( ) ) { $ hash = $ component -> getHash ( ) ; if ( array_key_exists ( $ hash , $ componentsLocated ) && ! empty ( $ componentsLocated [ $ hash ] ) && null !== $ componentsLocated [ $ hash ] -> getData ( ) ) { $ actionComponent -> setComponent ( $ componentsLocated [ $ hash ] ) ; } else { if ( $ this -> filterUnresolved ) { if ( $ collection instanceof PagerInterface ) { $ items = iterator_to_array ( $ collection -> getIterator ( ) ) ; unset ( $ items [ $ key ] ) ; $ collection -> setItems ( $ items ) ; } elseif ( is_array ( $ collection ) ) { unset ( $ collection [ $ key ] ) ; } else { throw new \ Exception ( 'Collection must be an array or a PagerInterface' ) ; } break ; } } } } } return $ collection ; }
|
Use locators to hydrate components .
|
53,987
|
private function guardValidIdentifier ( $ identifier ) { if ( null === $ identifier || '' === $ identifier ) { throw new ResolveComponentDataException ( 'No resolved identifier given' ) ; } if ( ! is_scalar ( $ identifier ) && ! is_array ( $ identifier ) ) { throw new ResolveComponentDataException ( 'Identifier has to be a scalar or an array' ) ; } }
|
Guard valid identifier .
|
53,988
|
protected function openFileObject ( $ mode , $ skipEmptyLines ) { if ( ! $ this -> getParent ( ) -> isDir ( ) ) { $ this -> getParent ( ) -> mkdirs ( ) ; } $ newFile = false ; if ( ! $ this -> isFile ( ) ) { switch ( $ mode ) { case 'w' : case 'w+' : case 'a' : case 'a+' : case 'x' : case 'x+' : $ newFile = true ; break ; } } $ this -> fileObject = $ this -> openFile ( $ mode ) ; if ( $ skipEmptyLines ) { $ this -> skipEmptyLines = true ; $ this -> fileObject -> setFlags ( \ SplFileObject :: DROP_NEW_LINE | \ SplFileObject :: READ_AHEAD | \ SplFileObject :: SKIP_EMPTY ) ; } else { $ this -> fileObject -> setFlags ( \ SplFileObject :: DROP_NEW_LINE ) ; } if ( $ newFile ) { $ this -> chmod ( $ this -> defaul_permission ) ; } }
|
file mode r = read only beginning of file r + = read and write beginning of file w = write only beginning of file empty file create file if necessary w + = read and write beginning of file empty file create file if nesessary a = write only end of file create file if necessary a + = read and write end of file create file if necessary x = write only beginning of file only create file x + = read and write beginning of file only create file
|
53,989
|
public function readLines ( ) { if ( $ this -> getFileObject ( ) -> isFile ( ) ) { if ( $ this -> skipEmptyLines ) { $ lines = file ( $ this -> getFileObject ( ) -> getPathname ( ) , FILE_SKIP_EMPTY_LINES | FILE_IGNORE_NEW_LINES ) ; } else { $ lines = file ( $ this -> getFileObject ( ) -> getPathname ( ) , FILE_IGNORE_NEW_LINES ) ; } if ( is_array ( $ lines ) ) { return $ lines ; } } return array ( ) ; }
|
return an array with all lines of a file
|
53,990
|
public function render ( $ indent = "\t" ) { $ html = '' ; foreach ( self :: $ storage as $ meta ) { $ html .= $ indent . $ meta -> render ( ) . PHP_EOL ; } return $ html ; }
|
Render all meta tags
|
53,991
|
public function hasMeta ( $ property ) { foreach ( static :: $ storage as $ meta ) { if ( $ meta -> getProperty ( ) == $ property ) { return true ; } } return false ; }
|
Check is meta exists
|
53,992
|
public function getMeta ( $ property ) { foreach ( static :: $ storage as $ meta ) { if ( $ meta -> getProperty ( ) == $ property ) { return $ meta -> getContent ( ) ; } } return false ; }
|
Get meta by property name
|
53,993
|
public function getExtension ( ) { if ( version_compare ( PHP_VERSION , '5.3.6' ) >= 0 ) { return parent :: getExtension ( ) ; } else { return ltrim ( pathinfo ( $ this -> getAbsolutePath ( ) , PATHINFO_EXTENSION ) , '.' ) ; } }
|
return file extension . method was implemented as of version 5 . 3 . 6 we will therefore check which version we got and extract the extension on our own otherwise
|
53,994
|
public function isAbsolute ( ) { $ filepath = $ this -> getPathname ( ) ; if ( isset ( $ filepath [ 0 ] ) && $ filepath [ 0 ] == self :: PATH_SEPARATOR ) { return true ; } return false ; }
|
return if file path is absolute
|
53,995
|
public function getAbsolutePath ( ) { if ( ! $ this -> isAbsolute ( ) ) { $ filepath = stream_resolve_include_path ( $ this -> getPathname ( ) ) ; } else { $ filepath = realpath ( $ this -> getPathname ( ) ) ; } return $ filepath ; }
|
return absolute file path
|
53,996
|
public function touch ( $ modificationTime = null , $ accessTime = null ) { if ( $ this -> isFile ( ) ) { if ( is_null ( $ modificationTime ) ) { $ modificationTime = time ( ) ; } if ( is_null ( $ accessTime ) ) { $ accessTime = $ modificationTime ; } return touch ( $ this -> getPathname ( ) , ( int ) $ modificationTime , ( int ) $ accessTime ) ; } else { throw new FileException ( 'File can not be touched, because it is no file or do not exist.' , E_NOTICE ) ; } }
|
touch set access and modification time to file
|
53,997
|
public function createNewFile ( $ mode = null ) { if ( $ this -> isAbsolute ( ) ) { if ( is_null ( $ mode ) ) { $ mode = $ this -> defaul_permission ; } if ( $ resource = fopen ( $ this -> getPathname ( ) , 'x' ) ) { fclose ( $ resource ) ; $ this -> chmod ( $ mode ) ; return true ; } return false ; } else { throw new FileException ( 'Given file path is not a absolute path.' ) ; } }
|
create a empty file named by the pathname
|
53,998
|
public function delete ( ) { if ( $ this -> isAbsolute ( ) ) { if ( $ this -> isFile ( ) || $ this -> isLink ( ) ) { return unlink ( $ this -> getPathname ( ) ) ; } elseif ( $ this -> isDir ( ) ) { return rmdir ( $ this -> getPathname ( ) ) ; } return false ; } else { throw new FileException ( 'Given file path is not a absolute path.' ) ; } }
|
delete the file or empty directory of the current file path
|
53,999
|
public function deleteAll ( ) { if ( $ this -> isAbsolute ( ) ) { if ( $ this -> isFile ( ) || $ this -> isLink ( ) ) { return unlink ( $ this -> getPathname ( ) ) ; } elseif ( $ this -> isDir ( ) ) { return $ this -> deleteAction ( $ this -> getPathname ( ) , true ) ; } return false ; } else { throw new FileException ( 'Given file path is not a absolute path.' ) ; } }
|
delete the file or directory with its content of the current file path
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.