Dataset Viewer
Auto-converted to Parquet Duplicate
idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
0
function sendDownloadConfirmation ( $ ticket ) { $ sendDownloadConfirmationRequest = new sendDownloadConfirmation ( ) ; $ sendDownloadConfirmationRequest -> targetId = $ ticket ; return $ this -> targetService -> sendDownloadConfirmation ( $ sendDownloadConfirmationRequest ) -> return ; }
Sends confirmation that the target resources was downloaded successfully by the customer .
1
function uploadTranslatable ( $ document ) { if ( ! isset ( $ this -> submission ) || ! isset ( $ this -> submission -> ticket ) ) { throw new Exception ( "Submission not initialized." ) ; } $ this -> _validateDocument ( $ document ) ; $ documentInfo = $ document -> getDocumentInfo ( $ this -> submission ) ; $ resource...
Uploads the document to project director for translation
2
function uploadTranslationKit ( $ fileName , $ data ) { $ result = "" ; $ resourceInfo = new ResourceInfo ( ) ; $ resourceInfo -> name = $ fileName ; $ resourceInfo -> size = strlen ( $ data ) ; $ workflowRequestTicket = $ this -> workflowService -> upload ( $ resourceInfo , $ data ) -> return ; $ uploadFinished = fals...
Uploads preliminary delivery file to project director
3
public function renderAsBreadcrumb ( $ menu , array $ options = [ ] ) { $ options = array_merge ( [ 'template' => $ this -> defaultTemplate ] , $ options ) ; if ( ( ! is_array ( $ menu ) ) && ( ! $ menu instanceof ItemInterface ) ) { $ path = [ ] ; if ( is_array ( $ menu ) ) { if ( empty ( $ menu ) ) { throw new \ Inva...
Render an array or KNP menu as foundation breadcrumb .
4
protected function handleResponse ( $ response ) { $ ch = $ this -> ch ; if ( false !== $ response ) { $ curlInfo = curl_getinfo ( $ ch ) ; if ( $ this -> getCurlOption ( CURLOPT_HEADER ) ) { if ( false !== stripos ( $ response , "HTTP/1.1 200 Connection established\r\n\r\n" ) ) { $ response = str_ireplace ( "HTTP/1.1 ...
Parse response text
5
protected function triggerError ( $ status , \ ErrorException $ exception ) { $ this -> result = false ; $ this -> errorStatus = $ status ; $ this -> errorException = $ exception ; $ this -> error && call_user_func ( $ this -> error , $ this , $ status , $ exception ) ; }
Trigger error callback
6
protected function parseResponse ( $ data , & $ exception ) { switch ( $ this -> dataType ) { case 'json' : case 'jsonObject' : $ result = json_decode ( $ data , $ this -> dataType === 'json' ) ; if ( null === $ result && json_last_error ( ) != JSON_ERROR_NONE ) { $ exception = new \ ErrorException ( 'JSON parsing erro...
Parse response data by specified type
7
public function getCurlOption ( $ option ) { return isset ( $ this -> curlOptions [ $ option ] ) ? $ this -> curlOptions [ $ option ] : null ; }
Returns an option value of the current cURL handle
8
public function getResponseHeader ( $ name = null , $ first = true ) { if ( is_null ( $ name ) ) { return $ this -> responseHeader ; } $ name = strtoupper ( $ name ) ; $ headers = $ this -> getResponseHeaders ( ) ; if ( ! isset ( $ headers [ $ name ] ) ) { return $ first ? null : array ( ) ; } else { return $ first ? c...
Returns request header value
9
public function getResponseHeaders ( ) { if ( ! is_array ( $ this -> responseHeaders ) ) { $ this -> responseHeaders = array ( ) ; foreach ( explode ( "\n" , $ this -> responseHeader ) as $ line ) { $ line = explode ( ':' , $ line , 2 ) ; $ name = strtoupper ( $ line [ 0 ] ) ; $ value = isset ( $ line [ 1 ] ) ? trim ( ...
Returns response headers array
10
public function getResponseCookie ( $ name ) { $ cookies = $ this -> getResponseCookies ( ) ; return isset ( $ cookies [ $ name ] ) ? $ cookies [ $ name ] : null ; }
Returns the cookie value by specified name
11
public function get ( $ url , $ data = array ( ) , $ dataType = null ) { return $ this -> processMethod ( $ url , $ data , $ dataType , 'GET' ) ; }
Execute a GET method request
12
public function post ( $ url , $ data = array ( ) , $ dataType = null ) { return $ this -> processMethod ( $ url , $ data , $ dataType , 'POST' ) ; }
Execute a POST method request
13
public function put ( $ url , $ data = array ( ) , $ dataType = null ) { return $ this -> processMethod ( $ url , $ data , $ dataType , 'PUT' ) ; }
Execute a PUT method request
14
public function delete ( $ url , $ data = array ( ) , $ dataType = null ) { return $ this -> processMethod ( $ url , $ data , $ dataType , 'DELETE' ) ; }
Execute a DELETE method request
15
public function patch ( $ url , $ data = array ( ) , $ dataType = null ) { return $ this -> processMethod ( $ url , $ data , $ dataType , 'PATCH' ) ; }
Execute a PATCH method request
16
protected function processMethod ( $ url , $ data , $ dataType , $ method ) { return $ this -> __invoke ( array ( 'url' => $ url , 'method' => $ method , 'dataType' => $ dataType , 'data' => $ data ) ) ; }
Execute a specified method request
17
public function getCurlInfo ( $ option = null ) { return $ option ? curl_getinfo ( $ this -> ch , $ option ) : curl_getinfo ( $ this -> ch ) ; }
Get information from curl
18
public function setOption ( $ name , $ value = null ) { if ( is_array ( $ name ) ) { foreach ( $ name as $ k => $ v ) { $ this -> setOption ( $ k , $ v ) ; } return $ this ; } if ( method_exists ( $ this , $ method = 'set' . $ name ) ) { return $ this -> $ method ( $ value ) ; } else { $ this -> $ name = $ value ; retu...
Set option property value
19
public function setColsCount ( $ numCols , $ toCreate = true , $ width = NULL ) { if ( $ toCreate == true ) { $ count = $ this -> count ( ) ; if ( $ count == 0 || $ this -> hasOnlyCols ( $ count ) ) { for ( $ i = $ count ; $ i < $ numCols ; $ i ++ ) { $ this -> addItem ( new HtmlGridCol ( "col-" . $ this -> identifier ...
Defines the number of columns in the grid
20
protected function buildUrl ( $ path ) { $ path = str_replace ( '%2F' , '/' , $ path ) ; $ path = str_replace ( ' ' , '%20' , $ path ) ; return rtrim ( $ this -> base , '/' ) . '/' . $ path ; }
Returns the URL to perform an HTTP request .
21
protected function head ( $ path ) { $ defaults = stream_context_get_options ( stream_context_get_default ( ) ) ; $ options = $ this -> context ; if ( $ this -> supportsHead ) { $ options [ 'http' ] [ 'method' ] = 'HEAD' ; } stream_context_set_default ( $ options ) ; $ headers = get_headers ( $ this -> buildUrl ( $ pat...
Performs a HEAD request .
22
protected function parseMetadata ( $ path , array $ headers ) { $ metadata = [ 'path' => $ path , 'visibility' => $ this -> visibility , 'mimetype' => $ this -> parseMimeType ( $ path , $ headers ) , ] ; if ( false !== $ timestamp = $ this -> parseTimestamp ( $ headers ) ) { $ metadata [ 'timestamp' ] = $ timestamp ; }...
Parses metadata out of response headers .
23
protected function parseMimeType ( $ path , array $ headers ) { if ( isset ( $ headers [ 'content-type' ] ) ) { list ( $ mimetype ) = explode ( ';' , $ headers [ 'content-type' ] , 2 ) ; return trim ( $ mimetype ) ; } list ( $ path ) = explode ( '#' , $ path , 2 ) ; list ( $ path ) = explode ( '?' , $ path , 2 ) ; retu...
Parses the mimetype out of response headers .
24
public function generate ( $ url ) { $ time = time ( ) ; $ query = parse_url ( $ url , PHP_URL_QUERY ) ; parse_str ( $ query , $ query ) ; $ query = $ this -> filterKeys ( $ query , $ this -> params ) ; $ query [ 'timestamp' ] = $ time ; $ signature = $ this -> generateToken ( $ query ) ; return $ url . '&timestamp=' ....
Generate a URL with signature
25
public function verify ( ) { $ time = $ this -> request -> getQuery ( 'timestamp' ) ; if ( $ this -> expireTime && time ( ) - $ time > $ this -> expireTime ) { return false ; } $ query = $ this -> request -> getParameterReference ( 'get' ) ; $ token = $ this -> request -> getQuery ( 'signature' ) ; unset ( $ query [ 's...
Verify whether the URL signature is OK
26
public function searchAndReplace ( $ text ) { $ state = 0 ; $ length = strlen ( $ text ) ; $ matches = [ ] ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ ch = $ text [ $ i ] ; $ state = $ this -> nextState ( $ state , $ ch ) ; foreach ( $ this -> outputs [ $ state ] as $ match ) { $ offset = $ i - $ this -> searchKeyw...
Search and replace a set of keywords in some text .
27
protected function processGetResult ( $ key , $ result , $ expire , $ fn ) { if ( false === $ result && ( $ expire || $ fn ) ) { if ( ! is_numeric ( $ expire ) && $ fn ) { throw new \ InvalidArgumentException ( sprintf ( 'Expire time for cache "%s" must be numeric, %s given' , $ key , is_object ( $ expire ) ? get_class...
Store data to cache when data is not false and callback is provided
28
public function setMulti ( array $ keys , $ expire = 0 ) { $ results = array ( ) ; foreach ( $ keys as $ key => $ value ) { $ results [ $ key ] = $ this -> set ( $ key , $ value , $ expire ) ; } return $ results ; }
Store multiple items
29
public function getFileContent ( $ file , $ fn ) { $ key = $ file . filemtime ( $ file ) ; return $ this -> get ( $ key , function ( $ wei , $ cache ) use ( $ file , $ fn ) { return $ fn ( $ file , $ wei , $ cache ) ; } ) ; }
Use the file modify time as cache key to store an item from a callback
30
protected function getChecksum ( $ string ) { $ checksum = '' ; foreach ( str_split ( strrev ( $ string ) ) as $ i => $ d ) { $ checksum .= ( $ i % 2 === 0 ) ? ( $ d * 2 ) : $ d ; } return ( 10 - array_sum ( str_split ( $ checksum ) ) % 10 ) % 10 ; }
Return the checksum char of luhn algorithm
31
public function setInis ( $ inis ) { foreach ( $ inis as $ name => $ value ) { ini_set ( 'session.' . $ name , $ value ) ; } $ this -> inis = $ inis + $ this -> inis ; return $ this ; }
Set session configuration options
32
protected function isActive ( ) { $ setting = 'session.use_trans_sid' ; $ current = ini_get ( $ setting ) ; if ( false === $ current ) { throw new \ UnexpectedValueException ( sprintf ( 'Setting %s does not exists.' , $ setting ) ) ; } $ result = @ ini_set ( $ setting , $ current ) ; return $ result !== $ current ; }
Check if session is started
33
public static function binToDec ( $ bin , $ length = 0 ) { $ gmp = gmp_init ( $ bin , 2 ) ; $ dec = gmp_strval ( $ gmp , 10 ) ; return self :: pad ( $ dec , $ length ) ; }
Converts binary string into decimal string .
34
public static function binToHex ( $ bin , $ length = 0 ) { $ gmp = gmp_init ( $ bin , 2 ) ; $ hex = gmp_strval ( $ gmp , 16 ) ; return self :: pad ( $ hex , $ length ) ; }
Converts binary string into hexadecimal string .
35
public static function decToHex ( $ dec , $ length = 0 ) { $ gmp = gmp_init ( $ dec , 10 ) ; $ hex = gmp_strval ( $ gmp , 16 ) ; return self :: pad ( $ hex , $ length ) ; }
Converts decimal string into hexadecimal string .
36
public static function rawToBin ( $ raw , $ length = 0 ) { $ gmp = gmp_import ( $ raw ) ; $ bin = gmp_strval ( $ gmp , 2 ) ; return self :: pad ( $ bin , $ length ) ; }
Converts stream of bytes into binary string .
37
public static function rawToDec ( $ raw , $ length = 0 ) { $ gmp = gmp_import ( $ raw ) ; $ dec = gmp_strval ( $ gmp , 10 ) ; return self :: pad ( $ dec , $ length ) ; }
Converts stream of bytes into decimal string .
38
public static function rawToHex ( $ raw , $ length = 0 ) { $ gmp = gmp_import ( $ raw ) ; $ hex = gmp_strval ( $ gmp , 16 ) ; return self :: pad ( $ hex , $ length ) ; }
Converts stream of bytes into hexadecimal string .
39
public static function pad ( $ input , $ length = 0 ) { $ input = ltrim ( $ input , '0' ) ; if ( $ input == '' ) { $ input = '0' ; } return str_pad ( $ input , $ length , '0' , STR_PAD_LEFT ) ; }
Pad left with zeroes to match given length .
40
public function setDriver ( $ driver ) { $ class = $ this -> wei -> getClass ( $ driver ) ; if ( ! class_exists ( $ class ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Cache driver class "%s" not found' , $ class ) ) ; } if ( ! is_subclass_of ( $ class , 'Wei\BaseCache' ) ) { throw new \ InvalidArgumentExcept...
Set cache driver
41
public function handle ( Request $ request , Closure $ next ) { $ response = $ next ( $ request ) ; $ this -> newRelic -> nameTransaction ( $ this -> getTransactionName ( $ request ) ) ; return $ response ; }
Handles the request by naming the transaction for New Relic
42
public function getTransactionName ( Request $ request ) { $ route = $ request -> route ( ) ; if ( is_array ( $ route ) ) { if ( isset ( $ route [ 1 ] ) && isset ( $ route [ 1 ] [ 'uses' ] ) ) { return $ route [ 1 ] [ 'uses' ] ; } elseif ( isset ( $ route [ 1 ] ) && isset ( $ route [ 1 ] [ 'as' ] ) ) { return $ route [...
Builds the transaction name . It will return the assigned controller action first then the route name before falling back to just index . php
43
protected function saveFile ( $ uploadedFile ) { $ ext = $ this -> getExt ( ) ; $ fullExt = $ ext ? '.' . $ ext : '' ; if ( $ this -> fileName ) { $ fileName = $ this -> fileName ; } else { $ fileName = substr ( $ uploadedFile [ 'name' ] , 0 , strlen ( $ uploadedFile [ 'name' ] ) - strlen ( $ fullExt ) ) ; } $ this -> ...
Save uploaded file to upload directory
44
public function getDisplayName ( ) { if ( $ this -> name !== '' ) { $ result = $ this -> name ; } else { $ result = '' ; $ string = trim ( $ this -> handle , '_-' ) ; $ segments = preg_split ( '/[_-]+/' , $ string ) ; foreach ( $ segments as $ segment ) { if ( $ segment !== '' ) { $ len = mb_strlen ( $ segment ) ; if (...
Get the package display name .
45
public function getSortedProductionVersions ( $ descending = false ) { $ versions = [ ] ; foreach ( $ this -> getVersions ( ) as $ v ) { if ( strpos ( $ v -> getVersion ( ) , Package \ Version :: DEV_PREFIX ) !== 0 ) { $ versions [ ] = $ v ; } } usort ( $ versions , function ( Package \ Version $ a , Package \ Version ...
Get the production versions sorted in ascending or descending order .
46
public function getSortedVersions ( $ descending = false , $ developmentVersionsFirst = null ) { if ( $ developmentVersionsFirst === null ) { $ versionComparer = new VersionComparer ( ) ; $ result = $ versionComparer -> sortPackageVersionEntities ( $ this -> getVersions ( ) -> toArray ( ) , $ descending ) ; } else { $ ...
Get the versions sorted in ascending or descending order with development or production versions first .
47
public function get ( $ key = null , $ default = null ) { return isset ( $ this -> entries [ $ key ] ) ? $ this -> entries [ $ key ] : $ default ; }
Get a key s value from the cache .
48
public function expired ( ) { if ( empty ( $ this -> entries ) ) { return true ; } if ( $ this -> timestampManager ) { return $ this -> timestampManager -> check ( $ this -> getTimestamp ( ) ) ; } return false ; }
Check if cached as expired .
49
public function save ( ) { $ updated = time ( ) ; $ this -> entries [ $ this -> timestampKey ] = $ updated ; if ( $ this -> timestampManager ) { $ this -> timestampManager -> update ( $ updated ) ; } return ( bool ) file_put_contents ( $ this -> path , json_encode ( $ this -> entries ) ) ; }
Save to cache .
50
public function importDirectory ( $ directory , $ packageHandle , $ packageVersion , $ basePlacesDirectory ) { $ parsed = $ this -> parser -> parseDirectory ( $ packageHandle , $ packageVersion , $ directory , $ basePlacesDirectory , ParserInterface :: DICTIONARY_NONE ) ; $ translations = $ parsed ? $ parsed -> getSour...
Parse a directory and extract the translatable strings and import them into the database .
51
public function matchPackageVersionEntities ( $ availableVersions , $ wantedVersion ) { if ( empty ( $ availableVersions ) ) { $ result = null ; } else { $ keys = [ ] ; foreach ( $ availableVersions as $ pv ) { $ keys [ $ pv -> getVersion ( ) ] = $ pv ; } $ bestKey = $ this -> matchPackageVersions ( array_keys ( $ keys...
Guess the best package version entity corresponding to a list of entity instances .
52
public function matchPackageVersions ( $ availableVersions , $ wantedVersion ) { $ m = null ; if ( preg_match ( '/^(\d+(?:\.\d+)*)(?:dev|alpha|a|beta|b|rc)/i' , $ wantedVersion , $ m ) ) { $ wantedVersionBase = $ m [ 1 ] ; } else { $ wantedVersionBase = $ wantedVersion ; } $ wantedVersionComparable = preg_replace ( '/^...
Guess the best package version entity corresponding to a list of versions .
53
public function fromPot ( Translations $ pot , LocaleEntity $ locale ) { $ cn = $ this -> app -> make ( EntityManager :: class ) -> getConnection ( ) ; $ po = clone $ pot ; $ po -> setLanguage ( $ locale -> getID ( ) ) ; $ numPlurals = $ locale -> getPluralCount ( ) ; $ searchQuery = $ cn -> prepare ( ' sele...
Fill in the translations for a specific locale .
54
public function getUnreviewedSelectQuery ( LocaleEntity $ locale ) { $ cn = $ this -> app -> make ( EntityManager :: class ) -> getConnection ( ) ; $ queryLocaleID = $ cn -> quote ( $ locale -> getID ( ) ) ; return $ cn -> executeQuery ( $ this -> getBaseSelectString ( $ locale , false , false ) . " inner join ...
Get the recordset of all the translations of a locale that needs to be reviewed .
55
public function getPackageSelectQuery ( PackageVersionEntity $ packageVersion , LocaleEntity $ locale , $ excludeUntranslatedStrings = false ) { $ cn = $ this -> app -> make ( EntityManager :: class ) -> getConnection ( ) ; $ queryPackageVersionID = ( int ) $ packageVersion -> getID ( ) ; return $ cn -> executeQuery ( ...
Get recordset of the translations for a specific package version and locale .
56
public function forPackage ( $ packageOrHandleVersion , LocaleEntity $ locale , $ excludeUntranslatedStrings = false ) { if ( $ packageOrHandleVersion instanceof PackageVersionEntity ) { $ packageVersion = $ packageOrHandleVersion ; } elseif ( is_array ( $ packageOrHandleVersion ) && isset ( $ packageOrHandleVersion [ ...
Get the translations for a specific package version and locale .
57
public function unreviewed ( LocaleEntity $ locale ) { $ rs = $ this -> getUnreviewedSelectQuery ( $ locale ) ; $ result = $ this -> buildTranslations ( $ locale , $ rs ) ; $ result -> setHeader ( 'Project-Id-Version' , 'unreviewed' ) ; return $ result ; }
Get the unreviewed translations for a locale .
58
public function localeHasPendingApprovals ( LocaleEntity $ locale ) { $ cn = $ this -> app -> make ( EntityManager :: class ) -> getConnection ( ) ; $ rs = $ cn -> executeQuery ( ' select CommunityTranslationTranslations.id from CommunityTranslationTra...
Does a locale have translation strings that needs review?
59
public function getColumnContent ( $ gridField , $ record , $ columnName ) { if ( ! $ record -> canView ( ) ) return ; $ field = GridField_FormAction :: create ( $ gridField , 'ExportSingle' . $ record -> ID , false , "exportsingle" , array ( 'RecordID' => $ record -> ID ) ) -> addExtraClass ( 'gridfield-button-export-...
Return the button to show at the end of the row
60
public function setUseLabelsAsHeaders ( $ value ) { if ( $ value === null ) { $ this -> useLabelsAsHeaders = null ; } else { $ this -> useLabelsAsHeaders = ( bool ) $ value ; } return $ this ; }
Set the DataFormatter s UseFieldLabelsAsHeaders property
61
public function getOne ( PackageVersionEntity $ packageVersion , LocaleEntity $ locale ) { $ array = $ this -> get ( $ packageVersion , $ locale ) ; return array_shift ( $ array ) ; }
Get some stats about a package version and a locale .
62
public function get ( $ wantedPackageVersions , $ wantedLocales ) { $ packageVersions = array_values ( array_unique ( $ this -> getPackageVersions ( $ wantedPackageVersions ) ) ) ; $ locales = array_values ( array_unique ( $ this -> getLocales ( $ wantedLocales ) ) ) ; $ qb = $ this -> createQueryBuilder ( 's' ) ; if (...
Get some stats about one or more package versions and one or more locales .
63
public function setGlobalAccess ( $ enable , $ user = 'current' ) { $ user = $ this -> getUser ( $ user ) ; if ( $ user === null ) { throw new UserMessageException ( t ( 'Invalid user' ) ) ; } if ( $ user -> getUserID ( ) === USER_SUPER_ID ) { return ; } $ group = $ this -> groups -> getGlobalAdministrators ( ) ; if ( ...
Set or unset global administration access .
64
protected function getWorktreeDirectory ( ) { if ( $ this -> worktreeDirectory === null ) { $ config = $ this -> app -> make ( 'community_translation/config' ) ; $ dir = $ config -> get ( 'options.tempDir' ) ; $ dir = is_string ( $ dir ) ? rtrim ( str_replace ( DIRECTORY_SEPARATOR , '/' , $ dir ) , '/' ) : '' ; if ( $ ...
Get the working tree directory .
65
protected function getGitDirectory ( ) { if ( $ this -> gitDirectory === null ) { $ this -> gitDirectory = $ this -> getWorktreeDirectory ( ) . '/.git' ; } return $ this -> gitDirectory ; }
Get the git directory .
66
public function getRootDirectory ( ) { $ dir = $ this -> getWorktreeDirectory ( ) ; $ relativeRoot = trim ( str_replace ( DIRECTORY_SEPARATOR , '/' , $ this -> gitRepository -> getDirectoryToParse ( ) ) , '/' ) ; if ( $ relativeRoot !== '' ) { $ dir .= '/' . $ relativeRoot ; } return $ dir ; }
Return the directory containing the files to be parsed .
67
public function update ( ) { $ fs = $ this -> getFilesystem ( ) ; if ( $ fs -> isDirectory ( $ this -> getGitDirectory ( ) ) ) { $ this -> runGit ( 'fetch origin --tags' ) ; } else { $ this -> initialize ( ) ; } }
Initializes or update the git repository .
68
private function runGit ( $ cmd , $ setDirectories = true ) { static $ execAvailable ; if ( ! isset ( $ execAvailable ) ) { $ safeMode = @ ini_get ( 'safe_mode' ) ; if ( ! empty ( $ safeMode ) ) { throw new UserMessageException ( t ( "Safe-mode can't be on" ) ) ; } if ( ! function_exists ( 'exec' ) ) { throw new UserMe...
Execute a git command .
69
public function getInputConceptsQuery ( $ data , $ concepts ) { foreach ( $ concepts as $ concept ) { $ data [ ] = $ this -> setData ( [ 'concepts' => [ [ 'name' => $ concept -> getName ( ) , 'value' => $ concept -> getValue ( ) , ] , ] , ] , 'input' ) ; } return $ data ; }
Generates Input Concept search query and adds it to existing data
70
public function getMetadataQuery ( $ data , $ metadata ) { foreach ( $ metadata as $ searchMetadata ) { $ data [ ] = $ this -> setData ( [ 'metadata' => $ searchMetadata ] , 'input' ) ; } return $ data ; }
Generates Metadata search query and adds it to existing data
71
public function getImagesQuery ( $ data , $ inputs ) { foreach ( $ inputs as $ input ) { $ data [ ] = $ this -> setData ( [ 'image' => [ 'url' => $ input -> getImage ( ) ] ] , 'input' ) ; } return $ data ; }
Generates Image search query and adds it to existing data
72
public function getReverseImagesQuery ( $ data , $ inputs ) { foreach ( $ inputs as $ input ) { $ data [ ] = [ 'output' => $ this -> setData ( [ 'image' => [ 'url' => $ input -> getImage ( ) ] ] , 'input' ) ] ; } return $ data ; }
Generates Reverse Image search query and adds it to existing data
73
public function getInputsFromSearchResult ( $ searchResult ) { $ input_array = [ ] ; if ( ! isset ( $ searchResult [ 'hits' ] ) ) { throw new \ Exception ( 'Hits Not Found' ) ; } foreach ( $ searchResult [ 'hits' ] as $ hit ) { if ( ! isset ( $ hit [ 'input' ] ) ) { throw new \ Exception ( 'Inputs Not Found' ) ; } $ in...
Parses Search Request Result and gets Inputs
74
public function getDisplayVersion ( ) { if ( $ this -> isDevVersion ( ) ) { return t ( '%s development series' , substr ( $ this -> version , strlen ( static :: DEV_PREFIX ) ) ) ; } else { return $ this -> version ; } }
Get the package version display name .
75
protected function genericHandle ( $ dataFormatterClass , $ ext , GridField $ gridField , $ request = null ) { $ items = $ this -> getItems ( $ gridField ) ; $ this -> setHeader ( $ gridField , $ ext ) ; $ formater = new $ dataFormatterClass ( ) ; $ formater -> setUseLabelsAsHeaders ( $ this -> useLabelsAsHeaders ) ; $...
Generic Handle request that will return a Spread Sheet in the requested format
76
protected function setHeader ( $ gridField , $ ext ) { $ do = singleton ( $ gridField -> getModelClass ( ) ) ; Controller :: curr ( ) -> getResponse ( ) -> addHeader ( "Content-Disposition" , 'attachment; filename="' . $ do -> i18n_plural_name ( ) . '.' . $ ext . '"' ) ; }
Set the HTTP header to force a download and set the filename .
77
protected function getItems ( GridField $ gridField ) { $ gridField -> getConfig ( ) -> removeComponentsByType ( 'GridFieldPaginator' ) ; $ items = $ gridField -> getManipulatedList ( ) ; foreach ( $ gridField -> getConfig ( ) -> getComponents ( ) as $ component ) { if ( $ component instanceof GridFieldFilterHeader || ...
Helper function to extract the item list out of the GridField .
78
public function buildFacebookLike ( ) { $ facebookLikeProvider = new FacebookLikeProvider ( array ( 'layout' => $ this -> configResolver -> getParameter ( 'facebook_like.layout' , 'ez_share_buttons' ) , 'width' => $ this -> configResolver -> getParameter ( 'facebook_like.width' , 'ez_share_buttons' ) , 'showFaces' => $...
Builds Facebook like button provider .
79
public function buildFacebookRecommend ( ) { $ facebookRecommendProvider = new FacebookRecommendProvider ( array ( 'layout' => $ this -> configResolver -> getParameter ( 'facebook_recommend.layout' , 'ez_share_buttons' ) , 'width' => $ this -> configResolver -> getParameter ( 'facebook_recommend.width' , 'ez_share_butt...
Builds Facebook recommend button provider .
80
public function buildTwitter ( ) { $ twitterProvider = new TwitterProvider ( array ( 'showUsername' => $ this -> configResolver -> getParameter ( 'twitter.show_username' , 'ez_share_buttons' ) , 'largeButton' => $ this -> configResolver -> getParameter ( 'twitter.large_button' , 'ez_share_buttons' ) , 'language' => $ t...
Builds Twitter button provider .
81
public function buildLinkedin ( ) { $ linkedinProvider = new LinkedinProvider ( array ( 'countMode' => $ this -> configResolver -> getParameter ( 'linkedin.count_mode' , 'ez_share_buttons' ) , 'language' => $ this -> configResolver -> getParameter ( 'linkedin.language' , 'ez_share_buttons' ) , ) ) ; return $ linkedinPr...
Builds Linkedin button provider .
82
public function buildGooglePlus ( ) { $ googlePlusProvider = new GooglePlusProvider ( array ( 'size' => $ this -> configResolver -> getParameter ( 'google_plus.size' , 'ez_share_buttons' ) , 'annotation' => $ this -> configResolver -> getParameter ( 'google_plus.annotation' , 'ez_share_buttons' ) , 'width' => $ this ->...
Builds Google Plus button provider .
83
public function buildXing ( ) { $ xingProvider = new XingProvider ( array ( 'shape' => $ this -> configResolver -> getParameter ( 'xing.shape' , 'ez_share_buttons' ) , 'counter' => $ this -> configResolver -> getParameter ( 'xing.counter' , 'ez_share_buttons' ) , 'language' => $ this -> configResolver -> getParameter (...
Builds Xing button provider .
84
public function import ( RemotePackageEntity $ remotePackage ) { $ temp = $ this -> download ( $ remotePackage ) ; $ rootPath = $ this -> getRootPath ( $ temp ) ; $ this -> translatableImporter -> importDirectory ( $ rootPath , $ remotePackage -> getHandle ( ) , $ remotePackage -> getVersion ( ) , '' ) ; $ package = $ ...
Import a remote package .
85
public function getVisitsCountFromCurrentIP ( $ timeWindow ) { $ timeWindow = ( int ) $ timeWindow ; $ ipControlLog = $ this -> app -> make ( IPControlLog :: class ) ; return $ ipControlLog -> countVisits ( 'api' , new DateTime ( "-$timeWindow seconds" ) ) ; }
Get the number of visits from the current IP address since a determined number of seconds ago .
86
public function checkRateLimit ( ) { $ rateLimit = $ this -> getRateLimit ( ) ; if ( $ rateLimit !== null ) { list ( $ maxRequests , $ timeWindow ) = $ rateLimit ; $ visits = $ this -> getVisitsCountFromCurrentIP ( $ timeWindow ) ; if ( $ visits >= $ maxRequests ) { throw new UserMessageException ( t ( 'You reached the...
Check if the API Rate limit has been reached .
87
public function setDirectoryToParse ( $ value ) { $ this -> directoryToParse = trim ( str_replace ( DIRECTORY_SEPARATOR , '/' , trim ( ( string ) $ value ) ) , '/' ) ; return $ this ; }
Set the path to the directory to be parsed .
88
public function setDirectoryForPlaces ( $ value ) { $ this -> directoryForPlaces = trim ( str_replace ( DIRECTORY_SEPARATOR , '/' , trim ( ( string ) $ value ) ) , '/' ) ; return $ this ; }
Set the base directory for places .
89
public function addDetectedVersion ( $ version , $ kind , $ repoName ) { $ this -> detectedVersions [ $ version ] = [ 'kind' => $ kind , 'repoName' => $ repoName , ] ; return $ this ; }
Add a repository detected version .
90
public function setTagFilters ( array $ value = null ) { if ( $ value === null ) { $ this -> tagFilters = [ 'none' ] ; } elseif ( empty ( $ value ) ) { $ this -> tagFilters = [ 'all' ] ; } else { $ this -> tagFilters = $ value ; } return $ this ; }
Set the repository tag filters .
91
public function getTagFiltersExpanded ( ) { $ tagFilters = $ this -> getTagFilters ( ) ; if ( $ tagFilters === null ) { $ result = null ; } else { $ result = [ ] ; $ m = null ; foreach ( $ tagFilters as $ tagFilter ) { if ( preg_match ( '/^\s*([<>=]+)\s*(\d+(?:\.\d+)?)\s*$/' , $ tagFilter , $ m ) ) { switch ( $ m [ 1 ]...
Extracts the info for tag filter .
92
private function predict ( array $ image , $ modelType , $ language = null ) { $ data [ 'inputs' ] = [ [ 'data' => [ 'image' => $ image , ] , ] , ] ; if ( $ language ) { $ data [ 'model' ] = [ 'output_info' => [ 'output_config' => [ 'language' => $ language , ] , ] , ] ; } return $ this -> getRequest ( ) -> request ( '...
The actual predict call
93
public function predictUrl ( $ url , $ modelType , $ language = null ) { return $ this -> predict ( [ 'url' => $ url ] , $ modelType , $ language ) ; }
Predict by url
94
public function predictPath ( $ path , $ modelType , $ language = null ) { if ( ! file_exists ( $ path ) ) { throw new FileNotFoundException ( $ path ) ; } return $ this -> predict ( [ 'base64' => base64_encode ( file_get_contents ( $ path ) ) , ] , $ modelType , $ language ) ; }
Predict by image path
95
public function predictEncoded ( $ hash , $ modelType , $ language = null ) { return $ this -> predict ( [ 'base64' => $ hash , ] , $ modelType , $ language ) ; }
Predict base64 encoded image
96
public function train ( string $ id ) { $ modelResult = $ this -> getRequest ( ) -> request ( 'POST' , $ this -> getRequestUrl ( sprintf ( 'models/%s/versions' , $ id ) ) ) ; return $ this -> getModelFromResult ( $ modelResult ) ; }
Train the model
97
public function create ( Model $ model ) { $ data [ 'model' ] = $ this -> createModelData ( $ model ) ; $ modelResult = $ this -> getRequest ( ) -> request ( 'POST' , $ this -> getRequestUrl ( 'models' ) , $ data ) ; return $ this -> getModelFromResult ( $ modelResult ) ; }
Create new Model
98
public function update ( Model $ model ) { $ data [ 'models' ] = [ ] ; $ data [ 'models' ] [ ] = $ this -> createModelData ( $ model ) ; $ data [ 'action' ] = 'merge' ; $ modelResult = $ this -> getRequest ( ) -> request ( 'PATCH' , $ this -> getRequestUrl ( 'models' ) , $ data ) ; return $ this -> getModelsFromResult ...
Update the model
99
public function createModelData ( Model $ model ) { $ data = [ ] ; if ( $ model -> getId ( ) ) { $ data [ 'id' ] = $ model -> getId ( ) ; } if ( $ model -> getName ( ) ) { $ data [ 'name' ] = $ model -> getName ( ) ; } if ( $ model -> getConcepts ( ) ) { $ data [ 'output_info' ] [ 'data' ] = [ ] ; $ data [ 'output_info...
Create Model data for Request
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
3